2012-07-14 27 views

Trả lời

13

Bí quyết là:

FileInputStream fs = new FileInputStream(f); 
3

Bạn có thể sử dụng phương pháp này:

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 
    } 

hay này:

byte[] bytes = Files.readAllBytes(Paths.get("text.txt")); 
    String text = new String(bytes, StandardCharsets.UTF_8); 
Các vấn đề liên quan