public class Test {
public static void main(String[] args) {
File file = new File("C:\\download\\202104.json");
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
FileInputStream in = new FileInputStream(file);
in.read(filecontent);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
String fileStr1 = new String(filecontent);
System.out.println(fileStr1);
StringBuilder sb = new StringBuilder();
try {
BufferedReader reader = new BufferedReader(new FileReader("C:\\download\\202104.json"));
String s = null;
while ((s = reader.readLine()) != null) {
sb.append(s);
}
} catch (Exception e) {
e.printStackTrace();
}
String fileStr2 = sb.toString();
System.out.println(fileStr2);
}
}
|