import javafx.application.Application; //https://gluonhq.com/products/javafx/ https://github.com/openjdk/jfx import javafx.fxml.FXMLLoader; //https://gluonhq.com/products/javafx/ import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import java.io.IOException; import java.nio.file.DirectoryStream; import java.nio.*; import java.nio.file.Files; import java.nio.file.Files.*; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Scanner; import java.util.NoSuchElementException; import java.lang.IllegalStateException; Scanner input=new Scanner(System.in); System.out.printf("Enter file or directory name:"); Path path=Paths.get("D:\\书籍资料\\java\\JavaHowToProgram11e_EarlyObjects-master\\examples"); if(Files.exists(path)) { System.out.println("FileName:"+path.getFileName()); if(Files.isDirectory((path))) { try { DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path); for (Path p : directoryStream) { System.out.println(p.toString()); } } catch (IOException exception) { exception.printStackTrace(); } } } /**/ try(Scanner duinput=new Scanner(Paths.get("clients.txt"))) { System.out.printf("%-10s%-12s%-12s%10s%n", "Account","First Name", "Last Name", "Balance"); while (duinput.hasNext()) { // System.out.printf(""+ System.out.printf("%-10d%-12s%-12s%10.2f%n", duinput.nextInt(), duinput.next(), duinput.next(), duinput.nextDouble()); //System.out.printf("geovindu"); } } catch (IOException|NoSuchElementException|IllegalStateException exception) { exception.printStackTrace(); }
标签:Java,file,java,javafx,System,File,import,out From: https://www.cnblogs.com/geovindu/p/17135786.html