我一直堅持這一兩天,我只是無法找到一個很好的方法來打開.txt文件。我需要將其轉換爲多行字符串並將其設置爲textview。有人能幫助我嗎?如何將.txt文件轉換爲Android中的多行字符串Java
爲文件的位置,我使用的是:
String saveLoc = Environment.getExternalStorageDirectory()+"/My Documents/";
public String title;
public String Ftype = ".txt";
(saveLoc+title+Ftype) //is the file location.
我可以正常讀取數據到文件輸入流,但如果我試圖用它做任何事情,我得到這不會錯誤的負載讓我的應用程序甚至運行。
感謝回答得這麼快!但我不能使用預先定義的位置,程序打開用戶創建的文件,這就是爲什麼字符串'標題'留空。運行代碼塊的按鈕定義標題的值。 – user2406536
這樣也沒有問題,您可以輕鬆地從外部存儲器讀取文件。 –
哈哈怎麼樣?對不起,我對Android非常陌生,而且我對Java的這段時間並不熟悉。 – user2406536