Questions tagged [fileinputstream]

FileInputStream is a Java class meant for reading streams of raw bytes.

A FileInputStream is a Java class for reading the contents of a file from a stream. When you perform a read() on the stream, the appropriate data is read from the file and returned to the application.

1141 questions
3
votes
2 answers

Modify the bytes read by an InputStream while reading, not later

I need to make a simple sort of encryption so that the normal end user can't access some files easily. The files that are read by an FileInputStream are html files, pngs, jpegs and different simple text files (javascript, xml, ...) What I currently…
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
3
votes
1 answer

Cant find the newline character in a file (java)

I am trying to get the last line of a file, but my output shows that it never finds it. I also tried looking for "[" which all the lines start with, but unless the jumps were perfect the program will not skip "[". I tried looking for "\r\n",…
Juan
  • 521
  • 1
  • 11
  • 28
3
votes
1 answer

Unexpected end of ZLIB input stream in java

public class GzExtractor implements Extractor { Logger logger = LoggerFactory.getLogger(GzExtractor.class); private static final int BUFFER_SIZE = 1024; byte[] buff = new byte[BUFFER_SIZE]; private File file; private String…
3
votes
1 answer

Base64 decoding using apache commons codec failing on very large binary file

I am developing an encryption tool, and for our encrypted file format I am using Base64 to encode data. I am using apache commons codec to decode files using a Base64InputStream wrapped around a FileInputStream. This worked like a charm until I…
Lily Chung
  • 2,919
  • 1
  • 25
  • 42
3
votes
2 answers

Apache POI - java.lang.NoClassDefFoundError: org/apache/commons/compress/utils/InputStreamStatistics

I'm trying to read a word document (.docx) using Apache POI and it gives me this error... Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/compress/utils/InputStreamStatistics at…
3
votes
2 answers

read File from relative path using FileInputStream

I want to read a file from a relative path. I've tried the following code InputStream in = new FileInputStream(".//Audio//w1.wav"); Error: java.io.FileNotFoundException: .\Audio\w1.wav (The system cannot find the path specified) I also tried to…
3
votes
4 answers

FileInputStream Memory Leak in file read loop

we're facing a memory leak using a simple, simple, simple code as follows. The code is intended to get files from a source, use each file to do something and go on. This simple code uses always the same file but the behaviour is unchanged. package…
Mr.Gate
  • 419
  • 4
  • 12
3
votes
2 answers

Adding items to an array list of an array list

I'm wondering how to add items (from a Scanner that reads file input item by item) to an array list of arrays. Right now Eclipse is telling me that my .add does not work and I'm assuming it's because of the array list of arrays. Please help! public…
punchkey
  • 81
  • 1
  • 11
3
votes
6 answers

Opening a 12kb text file takes WAY too long....?

The following code works, but takes way too long (over a minute) to open a small file. The LogCat shows a lot of instances of "GC_FOR_MALLOC freed #### objects / ###### bytes in ##ms". Any suggestions? File dirPath = new…
Mr. Ricky
  • 61
  • 1
  • 4
3
votes
2 answers

Putting a URI into a FileInputStream

For an assignment, we are required to be able to save a custom file type and then be able to read it back in again. I figured I could use the FileInputStream class so that I could easily just use myInStream.read() to get all of the information I…
user3713569
  • 209
  • 1
  • 4
  • 13
3
votes
0 answers

Java - how to send a file to a client in chunks of 512 bytes (using FileInputStream?)

I need to send data packets to a client, and I need to send them as chunks of 512 bytes (last packet can be smaller than that). I have a file on my server folder but I'm not sure how can I read this file in chunks of 512 bytes, so I can insert them…
3
votes
1 answer

Getting the file used by a FileInputStream

Is it possible to obtain the File being used by a FileInputStream? FileInputStream does not appear to have any methods for retrieving it.
Jenna Sloan
  • 372
  • 8
  • 22
3
votes
3 answers

FileNotFoundException when reading a file, using absolute path

I'm trying to use an absolute path to read an file from file system but failed because of the "FileNotFoundException", which I don't know why File file=new File("E:\\Directory\\File.txt"); byte[] buff=new byte[8]; FileInputStream fileIn=new…
3
votes
1 answer

Resetting FileInputStream in Java so I can run multiple instances of another program in a test program

My problem is that I was assigned to modify and improve upon a program that does LZW compression. My program, as far as I know, runs fine, but relies on System.in and System.out redirection for the input file and output file. For my test program, I…
3
votes
2 answers

is possible to convert FileOutputStream to byte array?

I want to convert FileOutputStream to Byte array for passing binary data between two applications. please any one can help?
shakthivel
  • 199
  • 2
  • 3
  • 14