【问题标题】:how to read text file from computer on android如何在android上从计算机上读取文本文件
【发布时间】:2015-04-12 11:30:27
【问题描述】:

我有一个简单的 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;
    }

但它是“文件在该位置不存在”。吐司。

请帮帮我。

【问题讨论】:

    标签: android file


    【解决方案1】:

    默认情况下,您的 Android 设备无法访问您的台式计算机,而且它肯定没有 Windows 驱动器盘符。

    【讨论】:

    • @posteritysystem:不是这样。您可以创建某种在您的桌面上运行的服务器(例如,Web 服务器)并让您的 Android 应用程序与该服务器通信。您可以查看各种旧的 Windows SMB 样式文件共享协议。
    • 好的..谢谢你的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-08
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 2012-07-17
    • 1970-01-01
    相关资源
    最近更新 更多