java获取文件内容
话不多说,直接上代码
public static void main(String[] args) throws Exception {
test();
}
public static void test() throws Exception {
String s1="A:/fileTest/x.txt";
File file = new File(s1);
FileInputStream inputStream = new FileInputStream(file);
InputStreamReader readInputStream = new InputStreamReader(inputStream, "gb2312");
char[] b = new char[512];
int len = 0;
String str = "";
while((len = readInputStream.read(b)) != -1) {
str += new String(b, 0, len);
}
System.out.println(str.toString());
}