package essentials;

import java.nio.file.Files; import java.nio.file.Path;
import java.io.*; // Not recommended
import static java.lang.String.format; import static java.lang.System.*; // Not recommended
/** * This sample prints the current date and all the files in the current * directory with their size in bytes. It illustrates how packages can be * imported. * * In Java, the types necessary to compile and run a program are made available * through an environment variable, the CLASSPATH, and can be referenced by * their fully-qualified name. In contrast to other languages, in Java it is not * necessary to add any instruction to the source code to include dependencies. * However, we can import packages to simplify the names of external types and * members we wish to reference in our code. */ class Importing { public static void main(String[] args) throws IOException { System.out.println(new java.util.Date()); for( String fileName : new File(".").list() ) { out.println(format("%s (%d bytes)", fileName, Files.size(Path.of(fileName)))); } } }