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();
                }
        }

时间: 2024-11-10 07:10:27

android file path的相关文章

安卓各文件存储路径汇总(Android file path)

写下来,省得以后不记得到处翻: Environment.getDataDirectory() = /data Environment.getDownloadCacheDirectory() = /cache Environment.getExternalStorageDirectory() = /mnt/sdcard Environment.getExternalStoragePublicDirectory(“test”) = /mnt/sdcard/test Environment.getRo

《ArcGIS Runtime SDK for Android开发笔记》——问题集:Error:Error: File path too long on Windows, keep below 240 characters

1.前言 在使用Android Studio开发环境时,经常会爆出以下错误,虽然具体细节内容各有不同,但是说明的都是同一个问题,在windows中使用过长的路径,超过240字符. Error:Error: File path too long on Windows, keep below 240 characters : C:\Users\admin\Work\3-Code\4-ArcGIS Android Sample Code\ArcGISAndroidQuartzSample\vector

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, But form the development prospective, we should know about  Android internal structure. Android uses several partitions (like boot, system, recovery,

388. Longest Absolute File Path

题目如下: Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-dire

MAC上使用maven打android的包,报错:No Android SDK path could be found. 解决办法

修正: ANDROID_HOME=/Applications/Android/adt-bundle-mac-x86_64-20140321/sdklaunchctl setenv ANDROID_HOME $ANDROID_HOME http://blog.csdn.net/wirelessqa/article/details/17911811 对android工程运行mvn compile出现如下信息: No Android SDK path could be found. You may c

[LintCode] System Longest File Path

Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory 

Longest Absolute File Path -- LeetCode

Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory 

关于Android file.createNewFile() 失败的问题

[关于Android file.createNewFile() 失败的问题] 需要注意的是:要先对设计的文件路径创建文件夹 , 然后在对文件进行创建. 参考:http://blog.csdn.net/wjdarwin/article/details/7108606

"make_path" is not exported by the File::Path modul

之前正常运行的perl脚本换了一个环境突然报 从原来的make_path 和 remove_tree改为现在的mkpath 和 rmtree就好了. File::Path version is 1.08 on CentOS 5. "make_path" appears only in version 2.0. 参考: "make_path" is not exported by the File::Path modul FILE::PATH question