private FileReader m_Fr;
private BufferedReader m_Readbuf;
public int ReadStreamFile(String filepath)
{
//String str = Environment.getExternalStorageDirectory() + "/" + "test.apk";
//str == "mnt/sdcard/test.apk";
File file = new File(filepath);
if(!file.exists())
{
Log.d("文件不存在", " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
return -1;
}
try
{
m_Fr = new FileReader(filepath);
m_Readbuf = new BufferedReader(m_Fr);
String str = null;
while((str=m_Readbuf.readLine()) != null)
{
Log.i("一行字符串输出",str + "&&&&&&&&&&&&&&&&&&&&&&&");
}
}
catch (IOException ex)
{
ex.printStackTrace();
return -2;
}
return 0;
}
上面:
"Environment.getExternalStorageDirectory()" 是取到 SD卡的路径即:"/mnt/scard" 所以用的时候 在加上一个"/" 即变成 "/mnt/scard/" 然后后面就可以随便指定SD卡存放的东西了。
此读取文件功能是一行一行读取