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
4
votes
1 answer

Issue in reading french word from text file in java/android

I'm trying to read a french file contents (character by character) and checking there ascii value to do some operation.Everything works fine containing english alphabet but for character like àéèé, i'm facing some issue. For Example if my file…
Pranesh Sahu
  • 595
  • 5
  • 26
4
votes
2 answers

Getting wrong bytes from Java compared to C#

So I have some FRX binary files from which I am attempting to get string captions using Java's binary reading methods. I was capable of doing so, and specifying the region in which to read bytes in C# using the following program : using…
HavelTheGreat
  • 3,299
  • 2
  • 15
  • 34
4
votes
1 answer

Not getting file through FileInputStream?

I am trying to check file position so that it would not be overwritten. For this purpose I have to use FileInputStream because it has a method position() that can be use with FileChannel. BufferedReader does not maintain position. My code…
user3664724
  • 425
  • 1
  • 6
  • 18
4
votes
1 answer

FileInputStream negative skip

I'm trying to find more about history of java.io.FileInputStream.skip(n) operation when n is negative. According to InputStream documentation: If n is negative, no bytes are skipped. It seems that implementation of FileInputStream from Sun used to…
Peter Štibraný
  • 32,463
  • 16
  • 90
  • 116
4
votes
3 answers

Read a file, if it doesn't exist then create

Honestly, I've searched a lot do this task so I ended up trying various methods but nothing worked until I ended up on this code. It works for me perfectly like it should, so I do not want to change my code. The help I need is to put this code in a…
4
votes
3 answers

Write and read binary files in Android

I created a custom object of type Task and I want to save it in a binary file in internal storage. Here is the class I created: public class Task { private String title; private int year; private int month; private int day; …
miszu
  • 77
  • 1
  • 2
  • 5
4
votes
2 answers

How to do a multipart form-data in android with image and text?

I am building an app and at a certain point I need to upload an image to a server. When I only put the image as a parameter, it all works perfectly but the problem is when I add the text, nothing happens. Here is my code public int uploadFile(String…
Jayo2k
  • 251
  • 3
  • 14
4
votes
2 answers

java FileInputStream - differences based on how the File object is referenced: classloader/filesystem

I'm using apache POI to extract some data from an excel file. I need an InputStream to instantiate the POI HSSFWorkbook class HSSFWorkbook wb = new HSSFWorkbook(inputStreamX); I'm finding differences if I try to construct the InputStream object…
mickthompson
  • 5,442
  • 11
  • 47
  • 59
4
votes
2 answers

inside try block a FileIStream variable might not have been initialized error

I am trying to execute this code and I am also providing the valid argument but still I am getting error at line no. 34 and 35 that local variable fin and fout might not have been initialized. How to solve thisenter code here package…
Bijay Singh
  • 819
  • 4
  • 14
  • 33
4
votes
4 answers

Copying files in java

Would you please tell me why does this character " ÿ " appears at the end of my output file. (I use try/catch) File f1 = new File("C:/Users/NetBeansProjects/QuestionOne/input.txt"); File f2 = new…
4
votes
3 answers

Read Error when I click primefaces download second time

Hi i have implemented the example given in primefaces showcase for FileDownload When I render page and when i click on the download button for the first time I am able to download the file.But when click on download 2nd time it's giving me following…
mdp
  • 815
  • 4
  • 17
  • 32
4
votes
1 answer

How to test that FileInputStream has been closed?

how can I write a JUnit test, that checks if a FileInputStream has been closed? Consider the following code, import java.io.FileInputStream; class FileInputStreamDemo { public static void main(String args[]) throws Exception { …
Bertram Nudelbach
  • 1,783
  • 2
  • 15
  • 27
3
votes
2 answers

Android internal storage reading file

I have a problem with Android internal storage. I have created folder in package root folder calling getDir() and with MODE_WORLD_WRITEABLE because I want camera app to write captured image in this folder. Anyway, I can see that captured image is…
Emran
  • 1,031
  • 11
  • 25
3
votes
1 answer

Modifying FileInputStream for mediaPlayer setDataSource

I'm trying to modify (extend) the FileInputStream class so that I can open an encrypted file and use the stream for MediaPlayer's setDataSource(FileDescriptor). Problem is I don't know which method should be overridden to do the decryption inside…
josephus
  • 8,284
  • 1
  • 37
  • 57
3
votes
2 answers

Do Struts2 close the "InputStream" after they have got the result?

I have an action in struts 2 where it opens an FileInputStream, reads an image and shows it in a jsp. The question is that when struts is finished with getting the image, will it automatically take care of the FileInputStream and close() it or the…
Panos
  • 7,227
  • 13
  • 60
  • 95