Saturday, July 3, 2010

Guava Files util - my top methods

Guava makes Java code more Groovy-like. Now say hello to the Spring IO utils and Ant. Introducing

// Just write this fuckin' String to the file, man...
static void write(CharSequence from, File to, Charset charset)
static void append(CharSequence from, File to, Charset charset)

// File system operations
static void copy(File from, File to) 
static void deleteDirectoryContents(File directory)
static void deleteRecursively(File file)
static void move(File from, File to) 
static void touch(File file)

// No more annoying Java IO
static void createParentDirs(File file)
static File createTempDir()
static BufferedReader newReader(File file, Charset charset)
static BufferedWriter newWriter(File file, Charset charset) 
static List<String> readLines(File file, Charset charset)

No comments:

Post a Comment