====== File to String ======
===== Read the Whole File =====
Change YOUR_FILE to your actual file. You might want to change to charset for your file.
class Scratch {
static String readFile(String path, Charset encoding)
throws IOException {
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
}
public static void main(String[] args) {
try {
String s = readFile("404357 1 - SOP AF WT 2019.json", Charset.defaultCharset());
System.out.println(s);
} catch (IOException e) {
e.printStackTrace();
}
}
}
===== Read it by Line =====
class Scratch {
public static void main(String[] args) {
try {
Stream ss = Files.lines(Paths.get("YOUR_FILE"), Charset.defaultCharset());
Collection sss = ss.collect(Collectors.toList());
for (String s : sss) {
System.out.println(s);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}