1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| public void gettxt(){
BufferedReader r;
FileInputStream fis=null;
StringBuilder total=new StringBuilder();
// path=Environment.getExternalStorageDirectory().getPath();
// path=Environment.getExternalStorageDirectory();
path="/storage/emulated/0/download";
// path="/storage/sdcard0/download";
File file =new File(path,"Sherlock Holmes.txt");
// File file =new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"Sherlock Holmes.txt");
try{
fis= new FileInputStream(file);
r = new BufferedReader(new InputStreamReader(fis,"ISO-8859-1"));
while ((line = r.readLine()) != null) {
// line.getBytes();
total.append(line);
}
fis.close();
} catch (Exception e) {
e.printStackTrace();
str= e.getMessage();
}
str2 = total.toString();
} |
Partager