1
我有简单的Android应用程序从计算机硬盘读取文本文件。如何从Android上的计算机上读取文本文件
,所以我用的,
try
{
File myFile = new File("E:\\myFolder\\"+name);
Log.i("Test", "Path = "+myFile.getAbsolutePath().toString());
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn));
String aDataRow = "";
while ((aDataRow = myReader.readLine()) != null)
{
UpdateArray.add(aDataRow);
}
myReader.close();
return UpdateArray;
}
catch (FileNotFoundException e)
{
Toast.makeText(getBaseContext(), "File is Not Present at Location.", Toast.LENGTH_LONG).show();
return null;
}
catch (Exception e)
{
Toast.makeText(getBaseContext(), "Something Went Wrong.", Toast.LENGTH_LONG).show();
return null;
}
但它是“文件不在位置存在。”吐司。
请帮帮我。
哦!有没有其他的方式来实现这个? – posteritysystem
@posteritysystem:不是。您可以创建某种在您的桌面上运行的服务器(例如,Web服务器),并让您的Android应用程序与该服务器通信。您可以查看各种传统Windows SMB风格的文件共享协议。 – CommonsWare
好..感谢您的帮助。 – posteritysystem