我的java学习路之I/O流学习应用查找文件

来源:互联网 发布:郑爽 不吃饭知乎 编辑:程序博客网 时间:2024/09/21 06:34

//这是一个文件查看器DaKaiWenJianJia

public class DaKaiWenJianJia{

  public static void main(String[] args) throws Exception{

  JFileChooser filechooser = new JFileChooser();
  if(filechooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
  
  java.io.File file = filechooser.getSelectedFile();
  Scanner input = new Scanner(file);
  while(input.hasNext()){
  System.out.println(input.nextLine());
  }
  input.close();
  }else{
  System.out.println("没有找到文件夹!");
  }
  }

}

//new 一个JFileChooser文件选择器

0 0