public class Fozu {
public static void main(String[] args) {
readFileByLines("D:\\work\\cmp\\sq-server\\cmp\\src\\main\\resources\\banner.txt");
}
public static void readFileByLines(String fileName) {
File file = new File(fileName);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// 一次读一行,读入null时文件结束
while ((tempString = reader.readLine()) != null) {
Thread.sleep(500);
System.out.println(tempString);
line++;
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
}