Android FileOutputStream location save file

廉价感情. 提交于 2019-12-03 11:59:25
ρяσѕρєя K

Where can I find my file (data.txt)?

You can find the path of the directory, which is created by openFileOutput, by using YourActivity.this.getFilesDir().getAbsolutePath().

But I want "Hello" and "World" printed in two different lines.

Use line.separator after writing a word in a file, for example:

String separator = System.getProperty("line.separator");
outputStreamWriter.write(data);
outputStreamWriter.append(separator);
...

Or you can also use replaceAll to break String into multiple lines:

String separator = System.getProperty("line.separator");
data=data.replaceAll(" ",separator);

I guess you can find it here: data/data/[your package name]/... and regarding writing in two separate lines just add "\n" whenever you need to go to another line.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!