📄 simplethrows.java
字号:
import java.io.*;
/** A simple program that reads in its own source code and displays it to the
console. The program will crash if it encounters any errors. */
public class SimpleThrows
{
/** Returns the contents of the file pointed to by the parameter. */
public static String readFile(String file) throws IOException
{
FileReader fr = new FileReader(file); // can throw an exception
BufferedReader br = new BufferedReader(fr);
String temp, result = new String();
while ((temp = br.readLine()) != null) // can throw an exception
result += temp + "\n";
br.close();
return result; // return file contents
}
public static void main(String[] args) throws IOException
{
System.out.println(readFile("SimpleThrows.java"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -