public class FileTools {
//读取txt文件中的内容
public static String readFile(File file) throws IOException{FileInputStream inputStream = new FileInputStream(file);
int len=inputStream.available();
byte []buffer=new byte[len];
inputStream.read(buffer);
inputStream.close();
String content=new String(buffer);
return content;
}
//向txt文件中写入数据
public static void writeFile(File file,String content) throws IOException{FileOutputStream outputStream = new FileOutputStream(file);
outputStream.write(content.getBytes());
outputStream.close();
}
}