com.darwinsys.io
Class FileIO

java.lang.Object
  extended by com.darwinsys.io.FileIO

public class FileIO
extends java.lang.Object

Some file I-O primitives reimplemented in Java. All methods are static, since there is no state.

Version:
$Id: FileIO.java,v 1.24 2006/07/10 00:22:15 ian Exp $

Field Summary
protected static int BLKSIZ
          The size of blocking to use
static java.lang.String ENCODING_UTF_8
          String for encoding UTF-8; copied by inclusion from StringUtil.
 
Method Summary
static void copyFile(java.io.File file, java.io.File target)
          Copy a tree of files to directory, given File objects representing the files.
static void copyFile(java.io.InputStream is, java.io.OutputStream os, boolean close)
          Copy a file from an opened InputStream to opened OutputStream
static void copyFile(java.io.Reader is, java.io.Writer os, boolean close)
          Copy a file from an opened Reader to opened Writer
static void copyFile(java.lang.String inName, java.io.PrintWriter pw, boolean close)
          Copy a file from a filename to a PrintWriter.
static void copyFile(java.lang.String inName, java.lang.String outName)
          Copy a file from one filename to another
 void copyFileBuffered(java.lang.String inName, java.lang.String outName)
          Copy a data file from one filename to another, alternate method.
static void copyRecursively(java.io.File fromDir, java.io.File toDir)
           
static void copyRecursively(java.io.File fromDir, java.io.File toDir, boolean create)
          Copy all objects found in and under "fromdir", to their places in "todir".
static void copyRecursively(java.util.jar.JarFile base, java.util.jar.JarEntry startingDir, java.io.File toDir)
          Copy a tree of files to directory, given File objects representing the files.
static void deleteRecursively(java.io.File startDir)
           
static java.lang.String inputStreamToString(java.io.InputStream is)
          Read the content of a Stream into a String
static java.io.BufferedReader openFile(java.lang.String fileName)
          Open a BufferedReader from a named file.
static java.lang.String readerToString(java.io.Reader is)
          Read the entire content of a Reader into a String
static java.lang.String readLine(java.lang.String inName)
          Open a file and read the first line from it.
static void stringToFile(java.lang.String text, java.lang.String fileName)
          Write a String as the entire content of a File
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLKSIZ

protected static final int BLKSIZ
The size of blocking to use

See Also:
Constant Field Values

ENCODING_UTF_8

public static final java.lang.String ENCODING_UTF_8
String for encoding UTF-8; copied by inclusion from StringUtil.

See Also:
Constant Field Values
Method Detail

copyFile

public static void copyFile(java.lang.String inName,
                            java.lang.String outName)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Copy a file from one filename to another

Throws:
java.io.FileNotFoundException
java.io.IOException

copyFile

public static void copyFile(java.io.InputStream is,
                            java.io.OutputStream os,
                            boolean close)
                     throws java.io.IOException
Copy a file from an opened InputStream to opened OutputStream

Throws:
java.io.IOException

copyFile

public static void copyFile(java.io.Reader is,
                            java.io.Writer os,
                            boolean close)
                     throws java.io.IOException
Copy a file from an opened Reader to opened Writer

Throws:
java.io.IOException

copyFile

public static void copyFile(java.lang.String inName,
                            java.io.PrintWriter pw,
                            boolean close)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Copy a file from a filename to a PrintWriter.

Throws:
java.io.FileNotFoundException
java.io.IOException

copyFile

public static void copyFile(java.io.File file,
                            java.io.File target)
                     throws java.io.IOException
Copy a tree of files to directory, given File objects representing the files.

Parameters:
file - File representing the source, must be a single file.
target - File representing the location, may be file or directory.
Throws:
java.io.IOException

copyFileBuffered

public void copyFileBuffered(java.lang.String inName,
                             java.lang.String outName)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Copy a data file from one filename to another, alternate method. As the name suggests, use my own buffer instead of letting the BufferedReader allocate and use the buffer.

Throws:
java.io.FileNotFoundException
java.io.IOException

copyRecursively

public static void copyRecursively(java.io.File fromDir,
                                   java.io.File toDir,
                                   boolean create)
                            throws java.io.IOException
Copy all objects found in and under "fromdir", to their places in "todir".

Parameters:
fromDir -
toDir -
Throws:
java.io.IOException

copyRecursively

public static void copyRecursively(java.io.File fromDir,
                                   java.io.File toDir)
                            throws java.io.IOException
Throws:
java.io.IOException

deleteRecursively

public static void deleteRecursively(java.io.File startDir)
                              throws java.io.IOException
Throws:
java.io.IOException

copyRecursively

public static void copyRecursively(java.util.jar.JarFile base,
                                   java.util.jar.JarEntry startingDir,
                                   java.io.File toDir)
                            throws java.io.IOException
Copy a tree of files to directory, given File objects representing the files.

Parameters:
base - File representing the source, must be a single file.
startingDir -
toDir - File representing the location, may be file or directory.
Throws:
java.io.IOException

readLine

public static java.lang.String readLine(java.lang.String inName)
                                 throws java.io.FileNotFoundException,
                                        java.io.IOException
Open a file and read the first line from it.

Throws:
java.io.FileNotFoundException
java.io.IOException

readerToString

public static java.lang.String readerToString(java.io.Reader is)
                                       throws java.io.IOException
Read the entire content of a Reader into a String

Throws:
java.io.IOException

inputStreamToString

public static java.lang.String inputStreamToString(java.io.InputStream is)
                                            throws java.io.IOException
Read the content of a Stream into a String

Throws:
java.io.IOException

stringToFile

public static void stringToFile(java.lang.String text,
                                java.lang.String fileName)
                         throws java.io.IOException
Write a String as the entire content of a File

Throws:
java.io.IOException

openFile

public static java.io.BufferedReader openFile(java.lang.String fileName)
                                       throws java.io.IOException
Open a BufferedReader from a named file.

Throws:
java.io.IOException


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.