new BufferedReader in class Files cannot be applied to given types

Vaisakh MA

enter image description here

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 !!

Omar Abdullwahhab

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Constructor in class cannot be applied to given types

From Dev

java constructor in class cannot be applied to given types

From Dev

Issue with "Method in Class cannot be applied to given types"

From Dev

Constructor in class cannot be applied to given types

From Dev

Issue with "Method in Class cannot be applied to given types"

From Dev

Constructor in class cannot be applied to given types. Hope for assistance

From Dev

Error: Constructor Room in class Room cannot be applied to given types

From Dev

Java error: constructor in class cannot be applied to given types

From Dev

"constructor JSONParser in class JSONParser cannot be applied to given types" error occured

From Dev

Android: constructor ContactsAdapter in class ContactsAdapter cannot be applied to given types

From Dev

constructor in class cannot be applied to given types android studio

From Dev

Constructor in class cannot be applied to given types. Hope for assistance

From Dev

java: constructor ranngeIpScanner in class cannot be applied to given types;

From Dev

error: method addOutcome in class OutcomesTable cannot be applied to given types

From Dev

Method edit in class data access cannot be applied to given types

From Dev

method in class cannot be applied to given types; required: HashMap<String,Integer>

From Dev

Constructor cannot be applied to given types?

From Dev

Construtor cannot be applied to given types

From Dev

Java - error: constructor "constructor name" in class "class name" cannot be applied to given types;

From Dev

"Cannot be applied to given types" Error during PrintStream

From Dev

Java Polymorphism "cannot be applied to given types"

From Dev

How to fix method cannot be applied to given types

From Dev

Java, JOptionPane cannot be applied to given types

From Dev

Android Studio : cannot be applied into given types

From Dev

SQLite addData cannot be applied to given types

From Dev

Play Framework 2.2.1 - Compilation error: "method render in class index cannot be applied to given types;"

From Dev

How to resolve the Android error "method setSupportActionBar in class AppCompatActivity cannot be applied to given types"?

From Dev

Error Upon Compilation Java: "constructor LotteryTicket in class LotteryTicket cannot be applied to given types"

From Dev

Java beginners coding error - method contains in class String cannot be applied to given types

Related Related

  1. 1

    Constructor in class cannot be applied to given types

  2. 2

    java constructor in class cannot be applied to given types

  3. 3

    Issue with "Method in Class cannot be applied to given types"

  4. 4

    Constructor in class cannot be applied to given types

  5. 5

    Issue with "Method in Class cannot be applied to given types"

  6. 6

    Constructor in class cannot be applied to given types. Hope for assistance

  7. 7

    Error: Constructor Room in class Room cannot be applied to given types

  8. 8

    Java error: constructor in class cannot be applied to given types

  9. 9

    "constructor JSONParser in class JSONParser cannot be applied to given types" error occured

  10. 10

    Android: constructor ContactsAdapter in class ContactsAdapter cannot be applied to given types

  11. 11

    constructor in class cannot be applied to given types android studio

  12. 12

    Constructor in class cannot be applied to given types. Hope for assistance

  13. 13

    java: constructor ranngeIpScanner in class cannot be applied to given types;

  14. 14

    error: method addOutcome in class OutcomesTable cannot be applied to given types

  15. 15

    Method edit in class data access cannot be applied to given types

  16. 16

    method in class cannot be applied to given types; required: HashMap<String,Integer>

  17. 17

    Constructor cannot be applied to given types?

  18. 18

    Construtor cannot be applied to given types

  19. 19

    Java - error: constructor "constructor name" in class "class name" cannot be applied to given types;

  20. 20

    "Cannot be applied to given types" Error during PrintStream

  21. 21

    Java Polymorphism "cannot be applied to given types"

  22. 22

    How to fix method cannot be applied to given types

  23. 23

    Java, JOptionPane cannot be applied to given types

  24. 24

    Android Studio : cannot be applied into given types

  25. 25

    SQLite addData cannot be applied to given types

  26. 26

    Play Framework 2.2.1 - Compilation error: "method render in class index cannot be applied to given types;"

  27. 27

    How to resolve the Android error "method setSupportActionBar in class AppCompatActivity cannot be applied to given types"?

  28. 28

    Error Upon Compilation Java: "constructor LotteryTicket in class LotteryTicket cannot be applied to given types"

  29. 29

    Java beginners coding error - method contains in class String cannot be applied to given types

HotTag

Archive