ファイルを開くのに問題が発生しています。さて、私はすでにファイルがどこにあるかを知るために絶対パスを使用しましたが、それでもファイルを開くことができません(ファイルが見つかりません)
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(); }
}
問題はデバイスにファイルがないことだと思いますが、アプリの起動時にファイルをアップロードするにはどうすればよいですか?
前もって感謝します