android file path
问题 出现的异常为:java.lang.IllegalArgumentException: File /mnt/sdcard/crazyit.bin contains a pathseparator。
主要是由于在打开文件的输出流时使用的openFileOutput()方法的第一参数用于指定文件名称,不能包含路径分隔符“/”
解决方法 // FileInputStream fis =
openFileInput(sdCardDir.getCanonicalPath()+FILE_NAME);改为 FileInputStream fis = new
FileInputStream(sdCardDir.getCanonicalPath()+FILE_NAME)
对于InputStream的读取有两种方法
1.inputstream---》byte---》String
2.inputstream--->inputstreamReader---->BufferedRead-->string
android之sd文件读取模块
FileInputStream fileInputStream = null;
try {
File file = new File(Environment.getExternalStorageDirectory()
+ "/wipe.txt");
if (!file.exists())
file.createNewFile();
fileInputStream = new FileInputStream(file);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(fileInputStream));
String temapp;
while ((temapp = bufferedReader.readLine()) != null) {
apps.add(temapp);
Toast.makeText(MainActivity.this, temapp, Toast.LENGTH_LONG)
.show();
}
bufferedReader.close();
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} finally {
if (fileInputStream != null)
try {
fileInputStream.close();
} catch (IOException e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
android file path的更多相关文章
- 安卓各文件存储路径汇总(Android file path)
写下来,省得以后不记得到处翻: Environment.getDataDirectory() = /data Environment.getDownloadCacheDirectory() = /ca ...
- 《ArcGIS Runtime SDK for Android开发笔记》——问题集:Error:Error: File path too long on Windows, keep below 240 characters
1.前言 在使用Android Studio开发环境时,经常会爆出以下错误,虽然具体细节内容各有不同,但是说明的都是同一个问题,在windows中使用过长的路径,超过240字符. Error:Erro ...
- Android File Hierarchy : System Structure Architecture Layout
Most of the Android user are using their Android phone just for calls, SMS, browsing and basic apps, ...
- [LeetCode] Longest Absolute File Path 最长的绝对文件路径
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsub ...
- Android中Path类的lineTo方法和quadTo方法画线的区别
转载:http://blog.csdn.net/stevenhu_223/article/details/9229337 当我们需要在屏幕上形成画线时,Path类的应用是必不可少的,而Path类的li ...
- Longest Absolute File Path
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsub ...
- android 利用Path.cubicTo 画 贝塞尔曲线
Path.cubicTo void android.graphics.Path.cubicTo(float x1, float y1, float x2, float y2, float x3, fl ...
- OS X 禁止Android File Transfer自动启动
操作步骤 关闭Android File Manager 在Activity Manager中退出Android File Manager Agent进程 在Applications中,将Android ...
- Leetcode: Longest Absolute File Path
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsub ...
随机推荐
- AWS国际版的Route 53和CloudFront
注册AWS国际版账号后,却发现Route 53和CloudFront功能是无法使用的.于是提交了一个Service Request,得到的答复是这两个功能需要验证后才能激活. 在控制台中点击进入Rou ...
- Windows Azure文件共享服务--File Service
部署在Windows Azure上的虚拟机之间如何共享文件?例如:Web Server A和Web Server B组成负载均衡集群,两个服务器需要一个共享目录来存储用户上传的文件.通常,大家可能首先 ...
- CSS Sprite雪碧图应用
在写网页过程中,会遇到这种需要使用多个小图标: 如上图中的「女装」文字左边的图标.容易想到的解决方法是为每张图片加入<img>标签,但这样做会增加HTTP请求数量,影响网站加载速度.比这更 ...
- Vijos1680距离/openjudge2988计算字符串的距离[DP]
描述 设有字符串X,我们称在X的头尾及中间插入任意多个空格后构成的新字符串为X的扩展串,如字符串X为”abcbcd”,则字符串“abcb_c_”,“_a_bcbcd_”和“abcb_c_”都是X的扩展 ...
- Java面向对象编程 第二章 第一个Java应用
2.1创建Java源文件 Java应用由一个或多个扩展名为".java"的文件构成,这些文件被称为Java源文件,从编译的角度,则被称为编译单元. 本章包含两个Java源文件:Do ...
- CSS中单位px和em,rem的区别
PX特点: 1 IE无法调整那些使用px作为单位的字体大小: 2. 国外的大部分网站能够调整的原因在于其使用了em或rem作为字体单位: 3. Firefox能够调整px和em,rem,但是96%以上 ...
- splay总结
以此文纪念人生首次竞赛大选 这里主要讲一讲splay的区间操作,我讲的是指针实现,程序的效率可能比较低,更偏重代码的可读可写性,语言风格不是很优美有效,不喜勿喷 零.初始化结构体 1)这里主要是初始化 ...
- luogu1003铺地毯[noip2011 提高组 Day1 T1]
题目描述 为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯.一共有 n 张地毯,编号从 1 到n .现在将这些地毯按照编号从小到大的顺序平行于 ...
- js checkbox 选中判断
var isSelect = ""; isSelect = $("#tblImgList" + " input[type='checkbox']&qu ...
- WPF 4.0 DatePicker 快速录入
WPF 4.0的DatePicker在通过键盘录入日期的时候是非常让人郁闷的.必须按照日期的格式来完整输入例如,比如输入“2010/10/10”才能识别.而实际上在一些要求快速录入的场合,用户更希望直 ...