解决方案 »
- 为什么sdk 8 安装不了,崩溃了。。大神请看图
- intent.setClass()方法突然用不了呢?
- Android sdk 和 Google APIs的区别是什么?
- 翻转效果
- Android新手,请教几个关于Avd模拟器的问题
- 急急!!由于outstream = new FileOutputStream(f,true)引起的应用程序无响应错误
- Android怎么有效缩小图片以节省资源?
- Android显示电子书内容使用什么控件?
- layout可以显示,程序调用就出错
- 为什么4.4.4下的系统调用startActivityForResult()同时onActivityResult()被执行了
- Android客户端webservice服务端sql数据库根据Title查询信息
- 关于拍照功能Camera的预览问题。
byte[] buf = new byte[1024 * 10];
int read = 0;
while ((read = inputStream.read(buf)) != -1) {
file.write(buf, 0, read);}
存储到txt里面呢
FileOutputStream outStream = new FileOutputStream("/sdcard/"+name+".txt",true);
有这方面的例子或者讲解吗?
BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream("XXX.txt"));
byte[] b= new byte[1024];
out.write(b, 0, b.length);
当然,我这是简单的写法,你还要判断一下,因为我这里是小于等于1024个字节,如果多余,你就要使用while循环
//获取外存储设备路径Environment.getExternalStorageDirectory()
File file = new File(Environment.getExternalStorageDirectory(),name+".txt");
FileOutputStream outStream = new FileOutputStream(file);
outStream.write(content.getBytes());
outStream.close();
}
看了这样一段代码,没有理解整个存储的流程
read(byte)不能读short[] buffer
按照正常的文件的读取原则
File txt = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + "buf.txt");//存储文件路径+文件名。毫秒时间+buf。txt
if (!txt.exists()) {
try {
// 在指定的文件夹中创建文件
txt.createNewFile();
} catch (Exception e) {
}
}
FileWriter out = new FileWriter(txt);t = new FileWriter(txt);String str = "";
str = str + data.get(k) + "\n\t";out.write(str);
out.close();