【问题标题】:How to see path of written text file?如何查看写入文本文件的路径?
【发布时间】:2015-04-22 12:46:34
【问题描述】:

我想在我的 android 应用程序上查看带有 textView 的“abc.txt”路径。我该怎么做?

OutputStreamWriter out = new OutputStreamWriter(openFileOutput("abc.txt", Context.MODE_WORLD_READABLE));
        BufferedWriter bf = new BufferedWriter(out); 
bf.write("hello world");
bf.close();

编辑:形状像路径; emulated/legancy/android/data/com.hayro.project1/files/abc.txt 或其他东西。

【问题讨论】:

  • 根据您最近的编辑,您似乎正在模拟器上运行,并且想查看运行模拟器的系统上的文件路径?假设文件甚至是在系统上创建的(我不知道),你不知道那个模拟器系统的根在哪里吗?

标签: java android io


【解决方案1】:
File f = new File("abc.txt");
OutputStreamWriter out = new OutputStreamWriter(openFileOutput("abc.txt", Context.MODE_WORLD_READABLE));
    BufferedWriter bf = new BufferedWriter(out); 
bf.write("hello world");
bf.close();
System.out.println(f.getAbsolutePath());

我只是以 System.out 为例。您只需使用f.getAbsolutePath() 获取路径,然后将其分配给适当的变量。

【讨论】:

  • 结果:I/System.out:/abc.txt 我的期望是更深入的信息。
  • @hayroreis 这就是答案。我不确定你的评论应该做什么。
  • @hayroreis 没有更多信息。那是文件的路径。您的问题是,“我想在我的 android 应用程序上查看带有 textView 的“abc.txt”路径。我该怎么做?这就是如何。如果您还在寻找其他内容,您可能需要重新提出您的问题。
  • @hayoreis 我想我知道你在找什么。我编辑了我的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-09
  • 2020-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多