[英]File input output question with Inputstreamreader
我制作了一個Android應用,可將其寫入活動中的文件。 寫入文件的過程就像一種魅力:
FileOutputStream fOut = openFileOutput("myfeeds.txt", MODE_WORLD_READABLE); OutputStreamWriter osw = new OutputStreamWriter(fOut); osw.write(file); osw.flush(); osw.close();但是,當我想從其他活動讀取它時,找不到文件...該文件存在,我使用DDMS文件瀏覽器檢查了該文件。 讀取文件內容:
\n FileInputStream fis =新的FileInputStream(“ myfeeds.txt”); //找不到文件\n InputSource輸入=新的InputSource(fis);\n xr.setContentHandler(this);\n xr.parse(輸入);\n
我文件的正確位置是什么?
使用openFileInput
獲取使用openFileOutputStream寫入的那些文件的FileInputStream對象
使用以下代碼
FileInputStream fiss = openFileInput("myfeeds.txt");
InputSource input = new InputSource(fis);
xr.setContentHandler(this);
xr.parse(input);
你應該用
openFileInput( String name )
讀取您的文件。
此致,斯特凡
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.