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 ...
随机推荐
- Equinox P2的学习
product.configuration 点击“Add按钮”并添加以下插件: org.eclipse.equinox.p2.ui org.eclipse.equinox.p2.ui.sdk org. ...
- C#基础---扩展方法的应用
最近对扩展方法比较感兴趣,就看了看资料,记录一下扩展方法的几种方法. 一. 扩展方法的基本使用: Note: 1. 扩展方法必须在静态类中, 2 扩展方法必须声明静态方法,3 扩展方法里面不能调用其 ...
- APIO2013 tasksauthor
喜闻乐见的提答题,这道题还是蛮有趣的 数据结构题写得心塞,来一道提答意思意思 如果喜欢这类题的话还可以去做做uoj83. 这题是给出了两个问题,一个最短路,一个无向图染色问题. Data 1 Floy ...
- windows和ubuntu下gif动态图片的制作
现在社交软件中, 各种各样的动图为大家交流很大的乐趣. Gif图片比视频小, 比静态JPG图片形象生动, 更适用于产品展示和步骤演示等. 这里简单介绍一下在window系统和ubuntu系统下gif ...
- js 事件冒泡是什么如何用jquery阻止事件冒泡
什么是事件起泡:一个事件不能凭空产生,这就是事件的发生等等,接下来为大家介绍下jquery阻止事件起泡以及关于js事件起泡的验证,感兴趣的朋友可以参考下哈 (1)什么是事件起泡 首先你要明 ...
- [NOIP2010初赛]烽火传递+单调队列详细整理
P1313 [NOIP2010初赛]烽火传递 时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 烽火台又称烽燧,是重要的防御设施,一般建在险要处或交通要道上 ...
- .htaccess重命名时提示必须键入文件名怎么解决
在上一篇文章中提到过“目前data.uploads有执行.php权限,非常危险,需要立即取消目录的执行权限!”的时候可以通过创建一个名字为“.htaccess”的文件夹解决.但是在创建的时候却发现对记 ...
- 利用ThinkPHP自带的七牛云驱动上传文件到七牛云以及删除七牛云文件方法
一.准备工作 1.注册七牛云账号 2.选择对象储存->创建空间->设置为公开 3.在config配置文件中添加以下代码 'UPLOAD_FILE_QINIU' => array ( ...
- java:如何让程序按要求自行重启?
正文开始前的废话: 这里的程序即包括b/s的web application,也包括standalone的类c/s的java application. 为什么要自我重启? 场景1:分布式环境中, ...
- PRML读书会第十二章 Continuous Latent Variables(PCA,Principal Component Analysis,PPCA,核PCA,Autoencoder,非线性流形)
主讲人 戴玮 (新浪微博: @戴玮_CASIA) Wilbur_中博(1954123) 20:00:49 我今天讲PRML的第十二章,连续隐变量.既然有连续隐变量,一定也有离散隐变量,那么离散隐变量是 ...