程序目录中创建文件和读取写
FileOutputStream fos = this.openFileOutput("android.txt",MODE_APPEND);
fos.write("".getByte());
fos.flush();
fos.close();读
FileInputStream fis = this.openFileInput("android.txt");
FileOutputStream fos = this.openFileOutput("android.txt",MODE_APPEND);
fos.write("".getByte());
fos.flush();
fos.close();读
FileInputStream fis = this.openFileInput("android.txt");
解决方案 »
- Android ListView点击按钮产生的问题
- 大家帮忙看看 打包apk 问题吧。给个提示或思路也行谢谢了。。刚完成第一个android项目却不会打包。。。
- 加急,如何查看android的API隐藏函数
- android真机连接pc机,提示连接正常,但是adb命令执行不了
- 大牛们进来看看这个错误,给小弟指点迷津,不胜感激!!!!!!!!在线等。。。。。
- 安卓源代码编译后模拟出现NAND:bad arg:music怎么办
- android修改系统gps定位
- 求解决一个关于Eclipse建立至少支持低于Android4.0时Android项目报错问题。
- android地图
- 有大神研究Android APP连接UVC摄像头的吗,怎么获取提取使用视频流啊
- 请教关于Tabs页面里的onResume()复写问题
- 生成的AVD可以更改配置吗
public static void readFileByChars(String fileName) {
File file = new File(fileName);
Reader reader = null;
try {
System.out.println("----------------");
//
reader = new InputStreamReader(new FileInputStream(file));
int tempchar;
while ((tempchar = reader.read()) != -1) {
if (((char) tempchar) != '\r') {
System.out.print((char) tempchar);
mStr.append((char)tempchar);
}
}
Log.d("AndroidTest", "mStr.toString is:" + mStr.toString());
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
楼主这段代码如果有问题的话可能是文件地址的问题
是不是data/data/目录下没有访问权限?
我改为sdcard下是运行成功的,读取文件也正确。