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 { byte c = 70;/*from www . j ava 2 s .com*/ PrintStream ps = new PrintStream(new File("c:/text.txt")); // write byte c which is character F in ASCII ps.write(c); // flush the stream ps.flush(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte c = 70;//www . j av a 2s . c o m PrintStream ps = new PrintStream(new File("c:/text.txt"), "ASCII"); // write byte c which is character F in ASCII ps.write(c); // flush the stream ps.flush(); ps.close(); }
From source file:Main.java
public static void main(String[] argv) { append(new File("c:\\a.txt"), "value"); }
From source file:Main.java
public static void main(String[] args) { File aFile;//from ww w .j a v a 2 s . com try { aFile = new File(new URI("file:///c:/a.bat")); System.out.println(aFile.getName());//false } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) { // Create an object that is a directory File myFile = new File("test.txt"); System.out.println(myFile + (myFile.isHidden() ? " is" : " is not") + " hidden"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFile(f);/*from w w w. j a v a 2 s. c om*/ chooser.showOpenDialog(null); File curFile = chooser.getSelectedFile(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File(".").getCanonicalPath()); chooser.setCurrentDirectory(f);/*from w w w .ja v a 2s.c o m*/ chooser.setCurrentDirectory(null); chooser.showOpenDialog(null); File curDir = chooser.getCurrentDirectory(); }
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File("C:/ReadFile.txt"); FileInputStream fin = new FileInputStream(file); BufferedInputStream bin = new BufferedInputStream(fin); byte[] contents = new byte[1024]; int bytesRead = 0; String strFileContents;// w w w . ja v a 2s. c o m while ((bytesRead = bin.read(contents)) != -1) { strFileContents = new String(contents, 0, bytesRead); System.out.print(strFileContents); } bin.close(); }
From source file:CompareFileDates.java
public static void main(String[] args) { // Get the timestamp from file 1 String f1 = "run.bat"; long d1 = new File(f1).lastModified(); // Get the timestamp from file 2 String f2 = "build.xml"; long d2 = new File(f2).lastModified(); String relation;//from w w w . ja va 2 s . c om if (d1 == d2) relation = "the same age as"; else if (d1 < d2) relation = "older than"; else relation = "newer than"; System.out.println(f1 + " is " + relation + ' ' + f2); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFiles(new File[] { f }); chooser.showOpenDialog(null);//from w ww. jav a2s . c om File curFile = chooser.getSelectedFile(); }