2012-07-14 15 views

Odpowiedz

13

Sztuką jest taka:

FileInputStream fs = new FileInputStream(f); 
3

Można użyć tej metody:

BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(new FileInputStream(new File("text.txt"))))); 

    String line = null; 

    while ((line = reader.readLine()) != null) { 
     // do something with your read line 
    } 

czy to jedno:

byte[] bytes = Files.readAllBytes(Paths.get("text.txt")); 
    String text = new String(bytes, StandardCharsets.UTF_8); 
Powiązane problemy