我在打开文件时遇到了一些麻烦。好吧,我已经使用绝对路径知道文件在哪里,但它仍然无法打开文件(找不到文件)
public void ReadFromFile() throws FileNotFoundException
{
/** Read the contents of the given file. */
String SourceID = new String();
String LogicalID = new String();
File fileDir = getFilesDir();
String s = new String();
s+=fileDir.getAbsolutePath()+"/Nodes.txt";
Scanner scanner = new Scanner(new FileInputStream(s));
try
{
while (scanner.hasNextLine())
{
SourceID = scanner.nextLine();
LogicalID = scanner.nextLine();
String ss = new String();
ss+=" ----------------> "+SourceID+" "+LogicalID+" ";
Log.v(TAG, ss);
ListaNodesSTART.add(new NodesToStart(SourceID,LogicalID));
}
}catch(Exception ee){//Log.v(TAG, "Could not read the file");
ERROR.setText("Could Not Read file Nodes.txt");
ErRorLog.setText("Could Not Read file Nodes.txt");}
finally{scanner.close(); }
}
我想问题是设备没有文件,但是,我如何在应用程序启动时上传它?
提前致谢