List of usage examples for java.io File File
public File(URI uri)
From source file:Main.java
public static void main(String[] a) throws Exception { File remoteFile = new File(new URI("file:///index.htm")); System.out.println(remoteFile); }
From source file:Main.java
public static void main(String[] args) { // create new file File f = new File("c:/test"); // array of files and directory String[] paths = f.list();//from ww w. ja v a2 s .co m // for each name in the path array for (String path : paths) { System.out.println(path); } }
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;//from w w w . jav a2 s . c o m } if (file.isFile() && file.canRead()) { System.out.println(file.getName() + " can be read from."); } if (file.isDirectory()) { System.out.println(file.getPath() + " is a directory containing..."); String[] files = file.list(); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); } } }
From source file:Main.java
public static void main(String[] args) { try {/*from w w w . j a v a 2s . c o m*/ File dir = new File("C:/"); String[] envArray = new String[2]; envArray[0] = ""; envArray[1] = ""; // create a process and execute notepad.exe and currect environment Runtime runTime = Runtime.getRuntime(); Process process = runTime.exec("notepad.exe", envArray, dir); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] a) throws Exception { File remoteFile = new File(new URI("file:///index.htm")); }
From source file:MP3Player.java
public static void main(String[] args) throws Exception { File file = new File("test.mp3"); MediaLocator mrl = new MediaLocator(file.toURL()); Player player = Manager.createPlayer(mrl); player.start();// www .j a v a 2 s. c om }
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File("C:\\a.txt"); PrintStream ps = new PrintStream(file); System.setOut(ps);//w w w. java2 s .com System.out.println("To File"); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { File f = new File("f"); if (!f.setReadOnly()) { System.out.println("Grrr! Can't set file read-only."); return;/*from w w w .j a va 2s . c om*/ } }
From source file:Main.java
License:asdf
public static void main(String[] args) throws Exception { // create new files File f = new File("c:/asdf/"); System.out.print(f.getParentFile()); }
From source file:Main.java
License:asdf
public static void main(String[] args) throws Exception { // create new files File f = new File("c:/asdf/"); System.out.print(f.getParent()); }