List< String> list = new ArrayList<>();
try (BufferedReader br = Files.newBufferedReader(Paths.get(path))) {
//br returns as stream and convert it into a List
list = br.lines().collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace();
}
StringBuilder sb = new StringBuilder();
for (String s : list) {
sb.append(s);
}
String json = sb.toString();
JSONParser parser = new JSONParser();
obj = parser.parse(json);
I am getting this error please help !!
I guess that you are using java 7 which has only one version of Files.newBufferedReader method which takes Charset as a second argument https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newBufferedReader(java.nio.file.Path,%20java.nio.charset.Charset) In Java 8 you will find the method you need https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newBufferedReader-java.nio.file.Path-
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments