How can I save a file in a selected folder in Java?
I need it like this: storage/emulated/0/myfile.txt
Is there is an example?
Asked
Active
Viewed 109 times
-2
-
this might be the answer for your question. https://stackoverflow.com/a/28184936/12913325 – Jay_Panchal Apr 01 '22 at 18:30
2 Answers
0
try (PrintWriter out = new PrintWriter("storage/emulated/0/myfile.txt")) {
out.println(text);
}
If this is not what you want you'll have to add more details

Brentspine
- 274
- 1
- 15
-1
I have published a library that saves files, and handles everything with one line of code only, you can find it here along with its documentation
and the answer to your question is so easy
String path = FileSaver
.get()
.save(inputStream,"your/path","file.mp3");

Abdel Wadoud
- 29
- 3
-
don't post the exact same answer to multiple questions - partcularly not to promote a library/ utility you wrote – kleopatra Jul 31 '22 at 21:53