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
5
votes
7 answers

How to read N amount of lines from a file?

I am trying to practice reading text from a file in java. I am little stuck on how I can read N amount of lines, say the first 10 lines in a file and then add the lines in an ArrayList. Say for example, the file contains 1-100 numbers, like so; - 1…
Hilbis White
  • 179
  • 2
  • 2
  • 7
5
votes
0 answers

Why is InputStream constructed from Channel much faster than one constructed from FileDescriptor?

When constructing an InputStream on a RandomAccessFile in order to have Kryo deserialize objects from it, it seems it makes a HUGE difference for performance whether one constructs the mediating InputStream through the file's Channel (gives good…
Jimmy Jam
  • 71
  • 3
5
votes
4 answers

when does FileInputStream.read() block?

The question is similar to the following two questions. Java InputStream blocking read Why is the FileInputStream read() not blocking? But I still cannot fully understand it. So far I think the read() method in following code will block due to the…
liam xu
  • 2,892
  • 10
  • 42
  • 65
4
votes
2 answers

Is it safe to access the same file by several FileInputStream?

As described in the title, I would like to open several FileInputStream object to access the same file to obtain data in different position. Is it safe to do that, thank you!
Kan Xiao
  • 43
  • 1
  • 3
4
votes
1 answer

How can I send a generic file to a jersey service and receive it correctly?

I'm developing a Jersey service that uses Dropbox's API. I need to post a generic file to my service (the service would be able to manage every kind of file as well as you can do with the Dropbox API). Client Side So, I've implemented a simple…
pierus
  • 41
  • 1
  • 3
4
votes
2 answers

Closing a FileInputStream used by struts' stream result

My web application generates an XML file. I'm using a Struts2 stream result to manage the download, here's the action in struts.xml:
user1065335
  • 53
  • 1
  • 5
4
votes
3 answers

Equivalent to FileInputStream in J2ME?

Is there any equivalent to FileInputStream in J2ME?
Abhishek
  • 39
  • 2
4
votes
1 answer

How to give a FileInputStream to a Videoview?

I would like to know how to give a FileInputStream to a Videoview. I can see that we have an API like setDataSource() for mediaplayer, in which you can give a file descriptor. Is this same kind of thing possible in videoView?
Navaneeth Sen
  • 6,315
  • 11
  • 53
  • 82
4
votes
1 answer

paste clipboard into shiny app?

Here is an example that I could browse a file as input, but instead of browsing I would like to paste the data from clipboard. Any idea ? if (interactive()) { ui <- fluidPage( sidebarLayout( sidebarPanel( fileInput("file1", "Choose CSV File", accept…
Ali Hadjihoseini
  • 941
  • 1
  • 11
  • 31
4
votes
4 answers

C++ Line into Vector

Wow I've been all over the place with questions today and I apologize if they seem to overlap, but for every question comes another question...Since one thing wont work......but I should use something else......etc. Anyways, I have a text…
user475353
4
votes
2 answers

How to go about saving an image in blob format to MySQL in Java

For the purpose of a task I have to store an image into MySQL as a blob format (even though it would have been better and ideal to store the image path in the database and keep the image in a folder in localcopy). So far I have researched and…
dark_illusion_909099
  • 1,067
  • 2
  • 21
  • 41
4
votes
2 answers

FileNotFound Exception while running on Apache Tomcat?

I have a simple web application which uses Apache Tomcat 6.0. I am trying to read properties file from the path "resources/mysql.properties". Here "resources" folder is outside the "src" folder. When I am trying to run the project as Java…
Jaydeep Ranipa
  • 421
  • 5
  • 16
4
votes
2 answers

How to automatically write and read from files?

I have a java application that has 3 ArrayList objects: items, customers and orders. I'm wondering how do I write these objects to a file when I close the application and then how do I read from the files when I start the application? This was the…
4
votes
2 answers

Reading an XML File using FileInputStream (for Java)?

For my project I have to serialize and deserialize a random tree using Java and XStream. My teacher made the Tree/RandomTree algorithms, so I don't have to worry about that. What I don't know how to do is this: I am using FileInputStream to…
ParseTheData
  • 147
  • 2
  • 4
  • 8
4
votes
1 answer

BufferedInputStream or FileInputStream IOException

I've just released an Android app that parses a local file and make some process with the data. Some days ago one of my customers has reported me an error, each time he tries to process his file the app crashes. This is the error log he sent…
Wonton
  • 1,033
  • 16
  • 33