private String readFile(String filename) {
String reads = "";
try {
FileInputStream fis = this.openFileInput(filename);
byte[] b = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while (fis.read(b) != -1) {
baos.write(b, 0, b.length);
}
baos.close();
fis.close();
reads = baos.toString();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return reads;
}
//str就是转换之后的string,即reads
private void saveFile(String str, String filename) {
FileOutputStream fos;
try {
fos = this.openFileOutput(filename, this.MODE_PRIVATE);
fos.write(str.getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String reads = "";
try {
FileInputStream fis = this.openFileInput(filename);
byte[] b = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while (fis.read(b) != -1) {
baos.write(b, 0, b.length);
}
baos.close();
fis.close();
reads = baos.toString();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return reads;
}
//str就是转换之后的string,即reads
private void saveFile(String str, String filename) {
FileOutputStream fos;
try {
fos = this.openFileOutput(filename, this.MODE_PRIVATE);
fos.write(str.getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}