📄 charactertest.java
字号:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.UnsupportedEncodingException;
public class CharacterTest {
public static String readFile(String fileName) {
try {
BufferedReader fr = new BufferedReader(new FileReader(fileName));
StringBuffer out = new StringBuffer();
String thisLine = new String();
while ((thisLine = fr.readLine()) != null) {
out.append(thisLine);
}
fr.close();
return out.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getString() {
String out = readFile("E:\\wangxining\\projects\\jsptutorial\\eclipse\\workspace\\HelloWorldProject\\HelloWorldProject\\JavaSource\\text.txt");
try {
out = new String(out.getBytes("Gb18030"), "utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return out;
}
public static void main(String args[]) {
String out = readFile("E:\\wangxining\\projects\\jsptutorial\\eclipse\\workspace\\HelloWorldProject\\HelloWorldProject\\JavaSource\\text.txt");
try {
out = new String(out.getBytes("Gb18030"), "utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("[" + out + "]");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -