打印文件中的内容

package intensiveexercise;

import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.stream.Stream;

public class Q12Files {

 public static void main(String[] args) {   

//  Path path = Paths.get("courses.txt");

//  Stream<String> fc = null;

//  try { //   fc = Files.lines(path);

//   

//   List<String> fcList = Files.readAllLines(path);

//   

//  } catch (IOException e) {

// 

 

//   e.printStackTrace();

//  }

//  fc.forEach(s -> System.out.println(s));      

Path file=Paths.get("Q:/Users/a496006.DMN1.000/Desktop/s.txt");     

 try {    Stream<String> fc=Files.lines(file);    

fc.forEach(s->System.out.println(s));    

//   List<String> fcList= Files.readAllLines(file);

//   fcList.forEach(s->System.out.println(s));  

 } catch (IOException e) {   

   e.printStackTrace();   }   

 }

}

posted @ 2017-01-17 10:06  mabelfdm  阅读(204)  评论(0编辑  收藏  举报