public static void WriteFile(String filenames,String content)
{
File file = new File("/sdcard/", filenames);
if (file.exists() || (!file.exists())) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file, false);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fos.write(content.getBytes());
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static String ReadFile(String filenames)
{
String content = null;
File myFile = new File("/sdcard/", filenames);
if (myFile.exists()) {
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(myFile);
}
catch (FileNotFoundException e2) {
return content;
}
try {
BufferedReader readerRead1 = new BufferedReader(new InputStreamReader(inputStream));
content = readerRead1.readLine();
} catch (IOException e1) {
// TODO Auto-generated catch block
return content;
}
}
return content;
}
No comments:
Post a Comment