//
String filePath = "";
// new File("").getAbsolutePath()
// this.getClass().getResorce("").getPath()
// this.getClass().getResourceAsStream("") InputStream。"" / Sources , / ./ ,../
FileInputStream inputStream = new FileInputStream(filePath);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String lineString;
while ((lineString = bufferedReader.readLine()) != null) {
//
}
bufferedReader.close();
inputStreamReader.close();
inputStream.close();
//
String filePath = "";
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)))) {
String lineString;
while ((lineString = bufferedReader.readLine()) != null) {
//
}
} catch (IOException iOException) {
iOException.printStackTrace();
}
//
String filePath2 = "C:/Users/Administrator/Desktop/result.txt";
File file = new File(filePath2);
//
if(file.exists()){
file.delete();
}
file.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(filePath2);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream);
BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter);
//
bufferedWriter.write(content + "
");
bufferedWriter.close();// , ,
fileOutputStream.close();