-2

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?

tquadrat
  • 3,033
  • 1
  • 16
  • 29
RD1706
  • 11
  • 3

2 Answers2

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

Github repository

and the answer to your question is so easy

String path = FileSaver
        .get()
        .save(inputStream,"your/path","file.mp3");
  • 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