gpt4 book ai didi

android - 在android中读/写文件

转载 作者:行者123 更新时间:2023-11-30 01:41:16 25 4
gpt4 key购买 nike

try {
PrintStream out = new PrintStream(openFileOutput("OutputFile.txt", MODE_PRIVATE));

str=mIn.getText().toString();
out.println(str);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}

我想问一下这段代码是否创建了一个名为(OutputFile)的文件?如果是,这个文件的路径在哪里??

最佳答案

i want to ask if this code create file called(OutputFile)

它创建一个名为 OutputFile.txt 的文件

and if yes where is the path of this file??

您可以使用 getFileStreamPath 检索它的路径,返回使用 openFileOutput

创建的文件
  File file = getFileStreamPath("OutputFile.txt");
String path = null;
if (file != null) {
path = file.getPath();
}

关于android - 在android中读/写文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34479530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com