List of usage examples for java.io File File
public File(URI uri)
From source file:Main.java
public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(new File("c:/text.txt"), StandardCharsets.UTF_8.name()); System.out.println(scanner.nextLine()); scanner.close();/*from w ww. j a v a2 s .co m*/ }
From source file:MainClass.java
public static void main(String[] a) { File aFile = new File("C:/myFile.text"); FileInputStream inputFile1 = null; FileDescriptor fd = null;//ww w. j a v a 2 s. co m try { inputFile1 = new FileInputStream(aFile); fd = inputFile1.getFD(); } catch (IOException e) { e.printStackTrace(System.err); System.exit(1); } FileInputStream inputFile2 = new FileInputStream(fd); }
From source file:Main.java
public static void main(String[] argv) { Set<File> all = new HashSet<File>(); getAllFileAndFolder(new File("c:\\"), all); }
From source file:ExecDemoRm.java
public static void main(String[] args) throws IOException { for (int i = 0; i < 10; i++) { new File("/tmp/ww" + i).createNewFile(); }/*ww w .j ava 2s .c o m*/ Runtime.getRuntime().exec("ls -l /tmp/ww? > /tmp/report"); Runtime.getRuntime().exec("rm -f /tmp/ww?"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { File file = new File("filename.txt"); ShellFolder sf = ShellFolder.getShellFolder(file); Icon icon = new ImageIcon(sf.getIcon(true), sf.getFolderType()); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); boolean enabled = chooser.isTraversable(new File("abc")); chooser.showOpenDialog(null);/*from w ww. ja va2 s. co m*/ }
From source file:Main.java
public static void main(String[] args) { File dir = new File("c:\\"); File[] files = dir.listFiles(); Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); for (int i = 0; i < files.length; i++) { File file = files[i];//from w ww . j a v a 2s. c o m System.out.printf("File %s - %2$tm %2$te,%2$tY%n= ", file.getName(), file.lastModified()); } Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE); for (int i = 0; i < files.length; i++) { File file = files[i]; System.out.printf("File %s - %2$tm %2$te,%2$tY%n= ", file.getName(), file.lastModified()); } }
From source file:MainClass.java
public static void main(String[] args) { File path = new File("."); String[] list;/*from w w w .j av a 2s .c o m*/ if (args.length == 0) list = path.list(); else list = path.list(new DirFilter(args[0])); Arrays.sort(list); for (int i = 0; i < list.length; i++) System.out.println(list[i]); }
From source file:Main.java
public static void main(String[] args) { // Change the dirPath value to list files from your directory String dirPath = "C:\\"; File dir = new File(dirPath); File[] list = dir.listFiles(); for (File f : list) { if (f.isFile()) { System.out.println(f.getPath() + " (File)"); } else if (f.isDirectory()) { System.out.println(f.getPath() + " (Directory)"); }// w ww . j a va 2 s. co m } }
From source file:Main.java
public static void main(String[] argv) throws Exception { File file = new File("filename"); FileChannel roChannel = new RandomAccessFile(file, "r").getChannel(); ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, (int) roChannel.size()); }