[英]Read File from Local Network like \\192.168.0.100\share\file.txt Android Code
请在Android代码中帮助我,以读取位于我共享的网络位置中的文件。
\\ 192.168.0.100 \\共享\\ file.txt的
try {
InputStream file = new FileInputStream("\\\\192.168.0.100\\share\\file.txt");
InputStreamReader inputStreamReader = new InputStreamReader(file);
BufferedReader br = new BufferedReader(inputStreamReader);
String line;
while ((line = br.readLine()) != null) {
if(line.contains("text")) {
line = line.substring(2, 5);
}
text.append(line);
text.append('\n');
}
tv.setText(text);
}
catch (IOException e) {
e.printStackTrace();
tv.setText(e.toString());
}
这不起作用...说找不到文件/目录...。我已经检查并确认共享位置..它正在与其他本地连接的计算机一起使用。
请帮我。
使用\\\\computer\\resource
语法作为文件路径是Windows特定的。 该路径不适用于“其他本地连接的计算机”,而适用于Windows计算机。 Android,其他Linux系统和其他Unix系统不支持该语法。
您可以使用JCIFS库与Windows共享进行对话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.