/**
* 向txt中写文件,清空之前的数据
* @param content
* @param fileName
* @return
* @throws Exception
*/
public static boolean writeTxtFile(String content, File fileName)
throws Exception {
RandomAccessFile mm = null;
boolean flag = false;
FileOutputStream o = null;
try {
o = new FileOutputStream(fileName);
o.write(content.getBytes("GBK"));
o.close();
mm = new RandomAccessFile(fileName, "rw");
mm.writeBytes(content);
flag = true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} finally {
if (mm != null) {
mm.close();
}
}
return flag;
}
* 向txt中写文件,清空之前的数据
* @param content
* @param fileName
* @return
* @throws Exception
*/
public static boolean writeTxtFile(String content, File fileName)
throws Exception {
RandomAccessFile mm = null;
boolean flag = false;
FileOutputStream o = null;
try {
o = new FileOutputStream(fileName);
o.write(content.getBytes("GBK"));
o.close();
mm = new RandomAccessFile(fileName, "rw");
mm.writeBytes(content);
flag = true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} finally {
if (mm != null) {
mm.close();
}
}
return flag;
}