List of usage examples for java.io File File
public File(URI uri)
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); File file = new File("filename.txt"); String fileTypeName = chooser.getTypeDescription(file); }
From source file:MainClass.java
public static void main(String[] a) throws java.net.MalformedURLException { java.net.URL u = new File("GetResource.java").toURL(); System.out.println(u);//from w w w. j a v a2 s. c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { RandomAccessFile file = new RandomAccessFile(new File("scores.html"), "rw"); for (int i = 1; i <= 6; i++) { System.out.println(file.readLine()); }// ww w. j a va 2s .c o m file.close(); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); File file = new File("c:\\Program Files"); file = new File("c:\\IO.SYS"); boolean isHidden = chooser.getFileSystemView().isHiddenFile(file); }
From source file:Main.java
public static void main(String args[]) throws MalformedURLException { File file = new File("The End"); URL url2 = file.toURI().toURL(); System.out.printf("Good url %s%n", url2); }
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File("data.csv"); FileReader fr = new FileReader(file); LineNumberReader lnr = new LineNumberReader(fr); // lnr.setLineNumber(400); String line = ""; while ((line = lnr.readLine()) != null) { System.out.println("Line Number " + lnr.getLineNumber() + ": " + line); }// w w w . j ava 2 s . c om fr.close(); lnr.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { File directory = new File("c:\\"); FileUtils.deleteDirectory(directory); }
From source file:Main.java
public static void main(String[] args) { File file = new File(args[0]); if (!file.exists()) { System.out.println(args[0] + " does not exist."); return;/*w w w. j a v a 2 s.c om*/ } if (!(file.isFile() && file.canRead())) { System.out.println(file.getName() + " cannot be read from."); return; } try { FileInputStream fis = new FileInputStream(file); char current; while (fis.available() > 0) { current = (char) fis.read(); System.out.print(current); } } catch (IOException e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String args[]) { try {//from w w w . ja v a2 s . com File file = new File("c:\\winnt"); System.out.println("getCanonicalPath() = " + file.getCanonicalPath()); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { File outFile = new File("stdout.txt"); PrintStream ps = new PrintStream(new FileOutputStream(outFile)); System.out.println(outFile.getAbsolutePath()); System.setOut(ps);/*from w ww . j a v a 2 s .co m*/ System.out.println("Hello world!"); System.out.println("Java I/O is cool!"); }