Questions tagged [fileoutputstream]

FileOutputStream is a Java class used to write bytes directly to a File or to a FileDescriptor.

FileOutputStream is a Java class used to write bytes directly to a File or to a FileDescriptor.

Whether or not a file is available or may be created depends upon the underlying platform. Some platforms, in particular, allow a file to be opened for writing by only one FileOutputStream (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open.

FileOutputStream is meant for writing streams of raw bytes such as image data. For writing streams of characters, consider using FileWriter.

1082 questions
9
votes
0 answers

Java FileOutputStream when will written bytes be ready for read?

Assuming I have 2 threads, one is writing to a FileOutputStream and one is reading from a FileInputStream. The first thread has written x bytes. When are the bytes considered as ready for reads? The flush() method has an empty implementation on…
galusben
  • 4,833
  • 3
  • 23
  • 45
8
votes
2 answers

how to find the path of file created using FileOutputStream

I created a file using FileOutputStream and it is an excel file (using HSSF Liberary) FileOutputStream fileOut = new FileOutputStream(text+".xls"); then I write what I need in my excel file (workbook) and then close the…
Hirad Gorgoroth
  • 167
  • 1
  • 2
  • 8
8
votes
1 answer

Why does saving a bitmap take so long?

So I have an app on Google Glass that takes a picture, then converts it to grayscale and overwrites the original image in memory: private void rGBProcessing (final String picturePath, Mat image) { //BitmapFactory Creates Bitmap objects from various…
8
votes
1 answer

Volley - download directly to file (no in memory byte array)

I'm using Volley as my network stack in a project I'm working on in Android. Part of my requirements is to download potentially very large files and save them on the file system. Ive been looking at the implementation of volley, and it seems that…
Gil Moshayof
  • 16,053
  • 4
  • 41
  • 54
8
votes
1 answer

OutputStreamWriter does not append

Original code and its working saving the data to the SD Card // Writing data to internal storage btnSaveData.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isSDCardWritable()) { String…
LadyWinter
  • 187
  • 5
  • 13
8
votes
1 answer

Java BufferedWriter, OutputStreamWriter able to write to closed FileOutputStream

I was expecting the following code to throw an exception when I goto write data to the Stream: File file = new File("test.txt"); FileOutputStream fs = new FileOutputStream(file); OutputStreamWriter ow = new OutputStreamWriter(fs); BufferedWriter…
craineum
  • 187
  • 1
  • 2
  • 6
7
votes
3 answers

No such file or directory in Android 10 (api 29)

I am working on a photo editor app in which after editing my picture I save it into my local storage. It is working fine till android 9 but not on android 10. It shows exception of "No such file or directory found" in Android 10. After some research…
7
votes
4 answers

Android: How to store data on internal memory?

It's perfectly described here how to do it, the only problem: He doesnt know the function openFileOutput(); private void saveSettingsFile() { String FILENAME = "settings"; String string = "hello world!"; …
OneWorld
  • 16,782
  • 18
  • 79
  • 130
7
votes
3 answers

java.io.FileNotFoundException: open failed: EACCES (Permission denied)

I got this error when I trying to storage a bitmap into storage File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "picture"); if (! path.exists()) { path.mkdirs(); if…
Alexander
  • 121
  • 1
  • 1
  • 6
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,693
  • 9
  • 37
  • 73
7
votes
0 answers

Recording video using MediaRecorder and FileOutputStream produces video file that can't be played

I am trying to implement the function where i can start and stop the video recording multiple times, and accumulate video data into a File. This is how i prepare my media recorder: private boolean prepareVideoRecorder(){ mMediaRecorder = new…
6
votes
3 answers

Android - downloading image from web, saving to internal memory in location private to app, displaying for list item

What I'm trying to do is this: I want my application to download an image from the Internet and save it to the phone's internal memory in a location that is private to the application. If there is no image available for the list item (i.e. it can't…
Keeb13r
  • 235
  • 3
  • 8
  • 18
6
votes
3 answers

java read / write construction

Can someone explain me why this construction wont work: while (fileInputStream.available()>0) { fileOutputStream.write(fileInputStream.read()); } and this one works just fine: while (fileInputStream.available()>0) { int data =…
Hikaru
  • 111
  • 7
6
votes
2 answers

Writing byte array to file. Not always getting expected result

I am using Java to write a byte array to a file. When I open my file in a hex editor I am not always seeing the bytes that I expected to be there. Here is my example code and contents of the output file: public static void main(String[] args) { …
esgeroth
  • 85
  • 7
6
votes
7 answers

Close a file created with FileOutputStream, for a next delete

I am currently facing some problem with a FileOutputStream in my Java code. Actually I am using a FileOutputStream for creating a file, but then once the file is created there is no way for deleting it. As far as I could understand, this may come…
user1619114
  • 131
  • 1
  • 2
  • 9
1 2
3
72 73