Copies all the bytes from one file to another.
Moves a file from one path to another.
Creates an empty file or updates the last updated timestamp on the same as the unix command of the same name.
Creates any necessary but nonexistent parent directories of the specified file.
Atomically creates a new directory somewhere beneath the system's temporary directory (as defined by the java.io.tmpdir system property), and returns its name. static boolean equal(File file1, File file2) Returns true if the files contains the same bytes.
File file = Files.createTempDir();
System.out.println(file.getAbsoluteFile());
//out /var/folders/9l/scf5txbx49746ds5wf8_mgxw0000gp/T/1399364716588-0
//$ ls -ld /var/folders/9l/scf5txbx49746ds5wf8_mgxw0000gp/T/1399364775049-0
//drwxr-xr-x 2 xionglie staff 68 May 6 16:26 /var/folders/9l/scf5txbx49746ds5wf8_mgxw0000gp/T/1399364775049-0
Returns a new ByteSink for writing bytes to the given file.
Returns a new ByteSource for reading bytes from the given file.
Returns a new CharSink for writing character data to the given file using the given character set.
Returns a new CharSource for reading character data from the given file using the given character set.
Returns the file extension for the given file name, or the empty string if the file has no extension.
Returns the file name without its file extension or path.
String fullName = "/tmp/wad/sdw1234.jpg";
System.out.println(Files.getFileExtension(fullName));
System.out.println(Files.getNameWithoutExtension(fullName));
// ---output---
//jpg
//sdw1234
Computes the hash code of the file using hashFunction.
HashCode md5 = Files.hash(file, Hashing.md5());
String hexStr = md5.toString();
Process the bytes of a file.
Reads the first line from a file.
Reads all of the lines from a file.
File file = new File("test.txt");
List<String> lines = null;
try {
lines = Files.readLines(file, Charsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
Streams lines from a File, stopping when our callback returns false, or we have read all of the lines.
Reads all bytes from a file into a byte array.
Reads all characters from a file into a String, using the given character set.