|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rakeshv.io.FileUtilities
public final class FileUtilities
A utility class that provides static methods for
common IO operations.
© Copyright 2005, Rakesh Vidyadharan
| Constructor Summary | |
|---|---|
private |
FileUtilities()
Default constructor. |
| Method Summary | |
|---|---|
private static boolean |
delete(java.io.File file)
Delete the specified file. |
static int |
delete(java.io.File directory,
boolean deleteDirectory)
Delete all the files and directories under the specified directory. |
static int |
delete(java.lang.String directory,
boolean deleteDirectory)
Delete all the files and directories under the specified directory. |
static void |
mkdirs(java.io.File file)
Create the parent directory tree for the specified file if required. |
static void |
writeToFiles(java.io.InputStream inputStream,
java.io.File[] files)
Read all the data from the specified InputStream and
write them to the specified files. |
static void |
writeToFiles(java.io.InputStream inputStream,
java.lang.String[] names)
Read all the data from the specified InputStream and
write them to the specified files. |
private static void |
writeToFiles(java.io.InputStream inputStream,
TeeOutputStream tee)
Read all the data from the specified InputStream and
write them to the specified TeeOutputStream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
private FileUtilities()
| Method Detail |
|---|
public static int delete(java.lang.String directory,
boolean deleteDirectory)
throws java.lang.SecurityException
delete( File, boolean ) with a new File
representing the specified directory.
directory - The directory whose children are to be deleted.deleteDirectory - Specify true if you wish to
delete the specified directory as well. Specify false
if you wish to preserve the specified directory.
java.lang.SecurityException - If the SecurityManager
prevented the directory or its children from being deleted.
public static int delete(java.io.File directory,
boolean deleteDirectory)
throws java.lang.SecurityException
directory - The directory whose children are to be deleted.deleteDirectory - Specify true if you wish to
delete the specified directory as well. Specify false
if you wish to preserve the specified directory.
java.lang.SecurityException - If the SecurityManager
prevented the directory or its children from being deleted.delete( File )public static final void mkdirs(java.io.File file)
parent for existence and create
if required.
java.lang.SecurityException - If errors are encountered while creating
the directory tree.
public static final void writeToFiles(java.io.InputStream inputStream,
java.lang.String[] names)
throws java.io.FileNotFoundException,
java.io.IOException
InputStream and
write them to the specified files.
The following code shows sample usage of this method.
import org.rakeshv.io.FileUtilities;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
public class test
{
public static void main( String[] args )
{
try
{
String[] names = {"/tmp/one.m4a", "/tmp/two.m4a", "/tmp/three.m4a"};
BufferedInputStream inputStream = new BufferedInputStream(
new FileInputStream(
"/Users/rakesh/Desktop/AaraadayaManu.m4a" ) );
FileUtilities.writeToFiles( inputStream, names );
}
catch ( Throwable t )
{
t.printStackTrace();
}
}
}
inputStream - The stream from which the data is to be read.names - The fully qualified names of the files to which the
data read is to be written.
java.io.FileNotFoundException - If the file(s) specified could not
be created.
java.io.IOException - If errors are encountered while reading the
data from the inputStream or while writing to the
file(s).TeeOutputStream.TeeOutputStream( String[] ),
writeToFiles( InputStream, TeeOutputStream )
public static final void writeToFiles(java.io.InputStream inputStream,
java.io.File[] files)
throws java.io.FileNotFoundException,
java.io.IOException
InputStream and
write them to the specified files.
inputStream - The stream from which the data is to be read.files - The files to which the data read is to be written.
java.io.FileNotFoundException - If the file(s) specified could not
be accessed.
java.io.IOException - If errors are encountered while reading the
data from the inputStream or while writing to the
file(s).TeeOutputStream.TeeOutputStream( File[] ),
writeToFiles( InputStream, TeeOutputStream )
private static final void writeToFiles(java.io.InputStream inputStream,
TeeOutputStream tee)
throws java.io.FileNotFoundException,
java.io.IOException
InputStream and
write them to the specified TeeOutputStream.
inputStream - The stream from which the data is to be read.tee - The tee to which the data read is to be
written.
java.io.IOException - If errors are encountered while reading the
data from the inputStream or while writing to the
file(s).
java.io.FileNotFoundException
private static boolean delete(java.io.File file)
throws java.lang.SecurityException
System.err
if errors were encountered while deleting the file.
file - The file which is to be deleted.
false if the file could
not be deleted.
java.lang.SecurityException - If the SecurityManager
prevented the file from being deleted.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||