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.

1128 questions
9
votes
2 answers

How to write a file using Intent.ACTION_CREATE_DOCUMENT

In simple words, I want to convert a viewgroup to a jpg image file. As Environment.getExternalStorageDirectory is deprecated, I use this intent Intent.ACTION_CREATE_DOCUMENT private void createFile(String mimeType, String fileName) { Intent…
Nasib
  • 1,173
  • 1
  • 13
  • 23
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
  • 5,948
  • 6
  • 33
  • 52
9
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
  • 389
  • 2
  • 4
  • 13
9
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
  • 141
  • 1
  • 1
  • 6
9
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…
9
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
  • 307
  • 6
  • 13
8
votes
3 answers

How to properly overwrite content of file using android storage access framework

>> Background I want to use the SAF (Storage Access Frameword) to save data files of my app to the user's desired location on storage media. I first create the file at app dedicated folder and then copy it to the file that users has selected from…
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,633
  • 4
  • 47
  • 58
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
  • 7
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
  • 17,512
  • 21
  • 86
  • 136
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
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

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…
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
  • 8
1 2
3
75 76