charactertest.java

来自「《JSP通用模块及典型系统开发实例导航》源代码」· Java 代码 · 共 45 行

JAVA
45
字号
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 + =
减小字号Ctrl + -
显示快捷键?