如何从Android上的计算机读取文本文件 [英] how to read text file from computer on android

查看:103
本文介绍了如何从Android上的计算机读取文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Android应用程序,可以从计算机的硬盘驱动器中读取文本文件.

I Have Simple Android Application to Read the text file from hard drive of computer .

所以我以前是,

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;
    }

但是它是该位置不存在文件".吐司.

But it is "File is Not Present at Location." Toast.

请帮助我.

推荐答案

默认情况下,您的Android设备无法访问您的台式计算机,并且肯定没有Windows驱动器号.

Your Android device has no access to your desktop computer by default, and it most certainly does not have Windows drive letters.

这篇关于如何从Android上的计算机读取文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆