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
8
votes
4 answers

Why is it that FileInputStream read is slower with bigger array

If I read bytes from a file into a byte[] I see that FileInputStream performance worse when the array is around 1 MB compared to 128 KB. On the 2 workstations I have tested it is almost twice as fast with 128 KB. Why is that? import…
Stig
  • 1,974
  • 2
  • 23
  • 50
8
votes
2 answers

Upload+ read an excel file in a jsp using POI

I want to read an excel file in JSP,for this I first uploaded the file in a folder in the :D partition named uploads using a web application project,and I tried to read the excel uploaded file with an another java projet.The both codes are…
8
votes
1 answer

How to build FileInputStream object with byte array as a parameter

I have a zip file and after decoding it I get a byte array now I want to create a FileInputStream object with that byte[] object. I dont want to create a file instead pass data content do FileInputStream. Is there any way ? following is the…
Rauf
  • 620
  • 1
  • 8
  • 20
7
votes
1 answer

Android: Can't Read From File using FileInputStream

I'm trying to read from a file called "quiz_questions.txt" in my res/raw folder. The code I have compiles, but it looks like it stops before it gets to the FileInputStream. Maybe it is opening it, but not reading it. I'm not sure. import…
7
votes
7 answers

Java: reading strings from a random access file with buffered input

I've never had close experiences with Java IO API before and I'm really frustrated now. I find it hard to believe how strange and complex it is and how hard it could be to do a simple task. My task: I have 2 positions (starting byte, ending byte),…
GreyCat
  • 16,622
  • 18
  • 74
  • 112
7
votes
2 answers

create and download the Zip file java

In my application there are no of documents(pdf) for a particular tender. I need to create a zip file from those pdf files and allow user to download it. Application is done in JavaEE with struts and mysql. when user clicks the download button this…
Bhugy
  • 711
  • 2
  • 8
  • 23
7
votes
2 answers

Android: open failed: ENOENT (No such file or directory)

Hi i am trying to read excel from assets and wanted to convert it into JSON, But i am getting the error: open failed:ENOENT(No such file or directory), searched many SO questions but could not find the solution Below is my code public void…
teekib
  • 2,821
  • 10
  • 39
  • 75
7
votes
4 answers

how do i know which filestream supports seek in Java

java.io.InputStream.skip() says "Throws: IOException - if the stream does not support seek, or if some other I/O error occurs." how do i know which filestream supports seek? when google i find Seekable, but i can see that simple FileInputStream,…
Rakesh Malik
  • 607
  • 1
  • 6
  • 27
7
votes
3 answers

How can I access a txt file in a jar with FileInputStream?

I am aware of the getResourceAsStream() method but there is an issue with the parser that reads the file, the whole structure was implemented to expect a FileInputStream() and the getResourceAsStream() returns an input stream which cannot be casted.…
topless
  • 8,069
  • 11
  • 57
  • 86
7
votes
3 answers

Reading any text file having strange encoding?

I have a text file with a strange encoding "UCS-2 Little Endian" that I want to read its contents using Java. As you can see in the above screenshot the file contents appear fine in Notepad++, but when i read it using this code, just garbage is…
Brad
  • 4,457
  • 10
  • 56
  • 93
6
votes
4 answers

Get FileNotFoundException when initialising FileInputStream with File object

I am trying to initialise a FileInputStream object using a File object. I am getting a FileNotFound error on the line fis = new FileInputStream(file); This is strange since I have opened this file through the same method to do regex many times. My…
Ankur
  • 50,282
  • 110
  • 242
  • 312
6
votes
3 answers

Is FileInputStream using buffers already?

When I am using FileInputStream to read an object (say a few bytes), does the underlying operation involve: 1) Reading a whole block of disk so that if I subsequently do another read operation, it wouldnt require a real disk read as that portion of…
AnkurVj
  • 7,958
  • 10
  • 43
  • 55
6
votes
4 answers

Java read object input stream into arraylist?

The method below is supposed to read a binary file into an arrayList. But getting a java.io.EOFException: at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553) at…
ash
  • 61
  • 1
  • 1
  • 3
6
votes
3 answers

Converting inputStream to FileInputStream?

I am in a problem - i need to read SecretKey from Android APK (e.g. key.keystore), for my app it has to be read as a FileInputStream, but from assets I am getting only inputStream. How to convert inputStream to FileInputStream? Or is there any other…
Waypoint
  • 17,283
  • 39
  • 116
  • 170
6
votes
5 answers

Why is the FileInputStream read() not blocking?

I've got a Writer program that writes one line of text to a file, then waits until the user hits return before it writes another line and then exits. Only after that is the file closed. The code: public class Writer { Writer() { } …
QQQuestions
  • 736
  • 8
  • 7
1 2
3
76 77