電子書軟件,wps手機版都可以打開TXT文件,操作方法如下:
成都網站建設、做網站介紹好的網站是理念、設計和技術的結合。創新互聯建站擁有的網站設計理念、多方位的設計風格、經驗豐富的設計團隊。提供PC端+手機端網站建設,用營銷思維進行網站設計、采用先進技術開源代碼、注重用戶體驗與SEO基礎,將技術與創意整合到網站之中,以契合客戶的方式做到創意性的視覺化效果。
1、首先在手機上找到并打開WPS。
2、進入頁面后,點擊使用選項按鈕。
3、然后在打開的頁面中,選擇所有文件。
4、然后在打開的所有文件頁面中,點選txt,它會自動搜索到文件。
5、此時文件被打開了的,如下圖所示,就完成了。
可以。這里使用的手機型號為華為H60-L02,其中的具體步驟如下:
1、首先點擊搜索本地文件,如圖所示。
2、然后輸入TXT來搜索,會看到對應的結果,如圖所示。
3、然后根據實際情況進行選擇,如圖所示。
4、最后即可刪android手機里一堆txt文件了,如圖所示。
在安卓手機上,可以使用電子書軟件、WPS軟件、office軟件打開txt文件的。
分以下幾個步驟:
首先對manifest注冊SD卡讀寫權限
AndroidManifest.xml?
?xml?version="1.0"?encoding="utf-8"??
manifest?xmlns:android="
package="com.tes.textsd"?
android:versionCode="1"?
android:versionName="1.0"??
uses-sdk?
android:minSdkVersion="8"?
android:targetSdkVersion="16"?/?
uses-permission?android:name="android.permission.WRITE_EXTERNAL_STORAGE"/?
application?
android:allowBackup="true"?
android:icon="@drawable/ic_launcher"?
android:label="@string/app_name"?
android:theme="@style/AppTheme"??
activity?
android:name="com.tes.textsd.FileOperateActivity"?
android:label="@string/app_name"??
intent-filter?
action?android:name="android.intent.action.MAIN"?/?
category?android:name="android.intent.category.LAUNCHER"?/?
/intent-filter?
/activity?
/application?
/manifest
創建一個對SD卡中文件讀寫的類
FileHelper.java?
/**?
*?@Title:?FileHelper.java?
*?@Package?com.tes.textsd?
*?@Description:?TODO(用一句話描述該文件做什么)?
*?@author?Alex.Z?
*?@date?2013-2-26?下午5:45:40?
*?@version?V1.0?
*/?
package?com.tes.textsd;?
import?java.io.DataOutputStream;?
import?java.io.File;?
import?java.io.FileOutputStream;?
import?java.io.FileWriter;?
import?java.io.FileInputStream;?
import?java.io.FileNotFoundException;?
import?java.io.IOException;?
import?android.content.Context;?
import?android.os.Environment;?
public?class?FileHelper?{?
private?Context?context;?
/**?SD卡是否存在**/?
private?boolean?hasSD?=?false;?
/**?SD卡的路徑**/?
private?String?SDPATH;?
/**?當前程序包的路徑**/?
private?String?FILESPATH;?
public?FileHelper(Context?context)?{?
this.context?=?context;?
hasSD?=?Environment.getExternalStorageState().equals(?
android.os.Environment.MEDIA_MOUNTED);?
SDPATH?=?Environment.getExternalStorageDirectory().getPath();?
FILESPATH?=?this.context.getFilesDir().getPath();?
}?
/**?
*?在SD卡上創建文件?
*?
*?@throws?IOException?
*/?
public?File?createSDFile(String?fileName)?throws?IOException?{?
File?file?=?new?File(SDPATH?+?"http://"?+?fileName);?
if?(!file.exists())?{?
file.createNewFile();?
}?
return?file;?
}?
/**?
*?刪除SD卡上的文件?
*?
*?@param?fileName?
*/?
public?boolean?deleteSDFile(String?fileName)?{?
File?file?=?new?File(SDPATH?+?"http://"?+?fileName);?
if?(file?==?null?||?!file.exists()?||?file.isDirectory())?
return?false;?
return?file.delete();?
}?
/**?
*?寫入內容到SD卡中的txt文本中?
*?str為內容?
*/?
public?void?writeSDFile(String?str,String?fileName)?
{?
try?{?
FileWriter?fw?=?new?FileWriter(SDPATH?+?"http://"?+?fileName);?
File?f?=?new?File(SDPATH?+?"http://"?+?fileName);?
fw.write(str);?
FileOutputStream?os?=?new?FileOutputStream(f);?
DataOutputStream?out?=?new?DataOutputStream(os);?
out.writeShort(2);?
out.writeUTF("");?
System.out.println(out);?
fw.flush();?
fw.close();?
System.out.println(fw);?
}?catch?(Exception?e)?{?
}?
}?
/**?
*?讀取SD卡中文本文件?
*?
*?@param?fileName?
*?@return?
*/?
public?String?readSDFile(String?fileName)?{?
StringBuffer?sb?=?new?StringBuffer();?
File?file?=?new?File(SDPATH?+?"http://"?+?fileName);?
try?{?
FileInputStream?fis?=?new?FileInputStream(file);?
int?c;?
while?((c?=?fis.read())?!=?-1)?{?
sb.append((char)?c);?
}?
fis.close();?
}?catch?(FileNotFoundException?e)?{?
e.printStackTrace();?
}?catch?(IOException?e)?{?
e.printStackTrace();?
}?
return?sb.toString();?
}?
public?String?getFILESPATH()?{?
return?FILESPATH;?
}?
public?String?getSDPATH()?{?
return?SDPATH;?
}?
public?boolean?hasSD()?{?
return?hasSD;?
}?
}
寫一個用于檢測讀寫功能的的布局
main.xml?
?xml?version="1.0"?encoding="utf-8"??
LinearLayout?xmlns:android="
android:layout_width="fill_parent"?
android:layout_height="fill_parent"?
android:orientation="vertical"??
TextView?
android:id="@+id/hasSDTextView"?
android:layout_width="fill_parent"?
android:layout_height="wrap_content"?
android:text="hello"?/?
TextView?
android:id="@+id/SDPathTextView"?
android:layout_width="fill_parent"?
android:layout_height="wrap_content"?
android:text="hello"?/?
TextView?
android:id="@+id/FILESpathTextView"?
android:layout_width="fill_parent"?
android:layout_height="wrap_content"?
android:text="hello"?/?
TextView?
android:id="@+id/createFileTextView"?
android:layout_width="fill_parent"?
android:layout_height="wrap_content"?
android:text="false"?/?
TextView?
android:id="@+id/readFileTextView"?
android:layout_width="fill_parent"?
android:layout_height="wrap_content"?
android:text="false"?/?
TextView?
android:id="@+id/deleteFileTextView"?
android:layout_width="fill_parent"?
android:layout_height="wrap_content"?
android:text="false"?/?
/LinearLayout
就是UI的類了
FileOperateActivity.class?
/**?
*?@Title:?FileOperateActivity.java?
*?@Package?com.tes.textsd?
*?@Description:?TODO(用一句話描述該文件做什么)?
*?@author?Alex.Z?
*?@date?2013-2-26?下午5:47:28?
*?@version?V1.0?
*/?
package?com.tes.textsd;?
import?java.io.IOException;?
import?android.app.Activity;?
import?android.os.Bundle;?
import?android.widget.TextView;?
public?class?FileOperateActivity?extends?Activity?{?
private?TextView?hasSDTextView;?
private?TextView?SDPathTextView;?
private?TextView?FILESpathTextView;?
private?TextView?createFileTextView;?
private?TextView?readFileTextView;?
private?TextView?deleteFileTextView;?
private?FileHelper?helper;?
@Override?
public?void?onCreate(Bundle?savedInstanceState)?{?
super.onCreate(savedInstanceState);?
setContentView(R.layout.main);?
hasSDTextView?=?(TextView)?findViewById(R.id.hasSDTextView);?
SDPathTextView?=?(TextView)?findViewById(R.id.SDPathTextView);?
FILESpathTextView?=?(TextView)?findViewById(R.id.FILESpathTextView);?
createFileTextView?=?(TextView)?findViewById(R.id.createFileTextView);?
readFileTextView?=?(TextView)?findViewById(R.id.readFileTextView);?
deleteFileTextView?=?(TextView)?findViewById(R.id.deleteFileTextView);?
helper?=?new?FileHelper(getApplicationContext());?
hasSDTextView.setText("SD卡是否存在:"?+?helper.hasSD());?
SDPathTextView.setText("SD卡路徑:"?+?helper.getSDPATH());?
FILESpathTextView.setText("包路徑:"?+?helper.getFILESPATH());?
try?{?
createFileTextView.setText("創建文件:"?
+?helper.createSDFile("test.txt").getAbsolutePath());?
}?catch?(IOException?e)?{?
e.printStackTrace();?
}?
deleteFileTextView.setText("刪除文件是否成功:"?
+?helper.deleteSDFile("xx.txt"));?
helper.writeSDFile("1213212",?"test.txt");?
readFileTextView.setText("讀取文件:"?+?helper.readSDFile("test.txt"));?
}?
}
網站名稱:關于androidtxt的信息
網站URL:http://vcdvsql.cn/article44/dsdegee.html
成都網站建設公司_創新互聯,為您提供網站建設、網站制作、網站收錄、網站改版、全網營銷推廣、小程序開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯