【Java开源代码栏目提醒】:网学会员--在 Java开源代码编辑为广大网友搜集整理了: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 + "]");
}
}
上一篇:
CharacterResponse.java
下一篇:
还记得,那年的风车吗?