简体   繁体   English

从本地网络读取文件,例如\\\\ 192.168.0.100 \\ share \\ file.txt Android代码

[英]Read File from Local Network like \\192.168.0.100\share\file.txt Android Code

please help me in android code for reading a file located in my shared network place.. 请在Android代码中帮助我,以读取位于我共享的网络位置中的文件。

\\192.168.0.100\\share\\file.txt \\ 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());
}

this is not working... saying File / Directory not found.... I have checked and confirmed shared location.. it is working with other locally connected computers. 这不起作用...说找不到文件/目录...。我已经检查并确认共享位置..它正在与其他本地连接的计算机一起使用。

Please help me. 请帮我。

Using the \\\\computer\\resource syntax as a file path is Windows-specific. 使用\\\\computer\\resource语法作为文件路径是Windows特定的。 That path doesn't work with "other locally connected computers", it works with Windows computers. 该路径不适用于“其他本地连接的计算机”,而适用于Windows计算机。 Android, other Linux systems, and other Unix systems don't support that syntax. Android,其他Linux系统和其他Unix系统不支持该语法。

You could use the JCIFS library to talk to your Windows shares. 您可以使用JCIFS库与Windows共享进行对话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM