O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required