Files

The following class demonstrates several different methods of the java.io.File class. These include getting the size of a file, renaming a file, and moving a file to a different directory. It also gives you some utility methods to do things you might commonly need to do, such as get the file size in bytes.

CommonFileTasks.java

 package net.javagarage.demo.io.files; import java.io.File; import java.io.IOException; import java.text.DecimalFormat; import java.text.NumberFormat; /**<p> * This class demonstrates a number of * typical things you need to do when working * with files. * </p> * @author eben hewitt * @see File, NumberFormat **/ public class CommonFileTasks { private static final String ps = File.separator; //enum new in 5.0 classname ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.