fileoutputstream

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

[亡魂溺海] 提交于 2020-11-28 08:25:56
问题 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 I found that getExternalFilesDir() is deprecated in android Q+. But I cannot find any proper way to do it in android 10. So please if anyone can provide a tutorial it would be really helpful. I've added and granted uses-permission android:name=

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

坚强是说给别人听的谎言 提交于 2020-11-28 08:23:51
问题 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 I found that getExternalFilesDir() is deprecated in android Q+. But I cannot find any proper way to do it in android 10. So please if anyone can provide a tutorial it would be really helpful. I've added and granted uses-permission android:name=

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

三世轮回 提交于 2020-05-09 06:32:38
问题 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 (!path.exists()) { return null; } } String timeStamp = new SimpleDateFormat("yyyyMMdd_HH_mm_ss", Locale.CHINA).format(new Date()); File imagePath = new File(path.getPath() + "_" + "IMG_" + timeStamp + ".jpg"); BufferedOutputStream fos; try { fos =new BufferedOutputStream(new

Write and read binary files in Android

北慕城南 提交于 2020-01-23 08:12:27
问题 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; private int hour; private int minute; public Task(String inputTitle, int inputYear, int inputMonth, int inputDay, int inputHour, int inputMinute) { this.title = inputTitle; this.year = inputYear; this.month = inputMonth; this.day = inputDay; this.hour = inputHour; this

Java read in single file and write out multiple files

寵の児 提交于 2020-01-15 12:44:27
问题 I want to write a simple java program to read in a text file and then write out a new file whenever a blank line is detected. I have seen examples for reading in files but I don't know how to detect the blank line and output multiple text files. fileIn.txt: line1 line2 line3 fileOut1.txt: line1 line2 fileOut2.txt: line3 回答1: Just in case your file has special characters , maybe you should specify the encoding . FileInputStream inputStream = new FileInputStream(new File("fileIn.txt"));

Unable to merge two mp3 files

可紊 提交于 2020-01-15 08:18:08
问题 public class MainActivity extends Activity { FileInputStream fistream2,fistream1; File newFile=new File(Environment.getExternalStorageDirectory() +File.separator +"newfolder" //folder name +File.separator +"media" +File.separator +"player"+File.separator+"theonkar10.mp3"); File newFile1=new File(Environment.getExternalStorageDirectory() +File.separator +"newfolder" //folder name +File.separator +"media" +File.separator +"player"+File.separator+"1.mp3"); File newFile2=new File(Environment

Camera not saving image and drops exception

坚强是说给别人听的谎言 提交于 2020-01-11 10:25:08
问题 I'm creating camera app. I'm doing that in fragment. I have FrameLayout where I add the camera, and one button for capture. There are 2 problems. Camera not saves the image. When I click second time on capture image, drops exception java.lang.RuntimeException: takePicture failed I don't know where's the problem, I'm using camera API first time. Camera I'm using only in portrait mode. And in manifests I added the permissions for camera and write external storage. I have one class where I'm

Best way to continuously write to file (50 times per second)

不打扰是莪最后的温柔 提交于 2020-01-07 06:42:19
问题 I am building an Android app which records Accelerometer and Gyroscope data to a text file. In most of the tutorials they use a method which involves creating two text files, and opening and closing them each 50 times per second. ie : private static void writeToFile(File file, String data) { FileOutputStream stream = null; try { stream = new FileOutputStream(file, true); stream.write(data.getBytes()); } catch (FileNotFoundException e) { Log.e("History", "In catch"); e.printStackTrace(); }

Java - Get Japanese from JTextField and save to File

会有一股神秘感。 提交于 2020-01-06 07:10:34
问题 I am trying to get Japanese input from a JTextField (with the getText() method) and saving that to a File. I am confident that it does get Japanese format from the JTextField since I can append() that String to a JTextArea and it will be in the correct Japanese Format. However, when I try to write to a File it only turns to gibberish! I have tried to use an OutputStreamWriter instantiated with StandardCharsets.UTF_8 and I have tried with a plain FileOutputStream where I send in the bytes from