|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.util.Files
public class Files
Static utility methods for processing files.
| Field Summary | |
|---|---|
static FileFilter |
FILES_ONLY_FILE_FILTER
A file filter that accepts all normal files, as specified by File.isFile(). |
static FileFilter |
NON_CVS_DIRECTORY_FILE_FILTER
A file filter that accepts files that are directories that are not named "CVS", ignoring case. |
static File |
TEMP_DIRECTORY
Deprecated. Use new
File(System.getProperty(TEMP_DIRECTORY_SYS_PROPERTY)) instead. |
| Method Summary | |
|---|---|
static String |
baseName(File file)
Returns prefix of the file's name, defined as the part of the name before the final period, or the whole name if there is no final period. |
static void |
copyFile(File from,
File to)
Copies the contents of one file into another. |
static File |
createTempFile(String fileName)
Deprecated. Use java.io.File.createTempFile(String,String) instead. |
static String |
extension(File file)
Returns the suffix of the file's name, defined as the part of the name after the final period, or null if there is no period in the name. |
static String |
fileToURLName(File file)
Deprecated. Instead of Files.fileToURLName(file) use
file.toURI().toURL().toString(). |
static File |
makeCleanDir(File file)
Deprecated. Implement with compound statements in java.io.File. |
static File |
makeCleanDir(File directory,
String name)
Deprecated. Implement with compound statements in java.io.File. |
static String |
prefix(String name)
Deprecated. Only used as part of baseName(File). |
static byte[] |
readBytesFromFile(File file)
Returns the array of bytes read from the specified file. |
static char[] |
readCharsFromFile(File file)
Deprecated. Use readCharsFromFile(file,Strings.UTF8) instead. |
static char[] |
readCharsFromFile(File file,
String encoding)
Reads all of the bytes from the specified file and convert them to a character array using the specified character set. |
static String |
readFromFile(File file)
Deprecated. Use readFromFile(file,Strings.UTF8) instead. |
static String |
readFromFile(File file,
String encoding)
Reads all of the bytes from the specified file and convert them to a string using the specified character set. |
static String[] |
readLinesFromFile(File file,
String encoding)
Deprecated. Use FileLineReader.readLineArray(File,String) instead. |
static Object |
readObjectFrom(File file)
Deprecated. Use com.aliasi.util.AbstractExteranlizable.readObject(File)
instead. |
static int |
removeDescendants(File file)
Remove the descendants of the specified directory, but not the directory itself. |
static int |
removeRecursive(File file)
Removes the specified file and if it is a directory, all contained files. |
static Object |
serializeDeserialize(Serializable in)
Deprecated. Use com.aliasi.util.AbstractExteranlizable.serializeDeserialize(Serializable) instead. |
static String |
suffix(String name)
Deprecated. Only used as part of extension(File). |
static void |
writeBytesToFile(byte[] bytes,
File file)
Writes the specified bytes to the specified file. |
static void |
writeCharsToFile(char[] chars,
File file)
Deprecated. Use writeCharsToFile(chars,file,Strings.UTF8) instead. |
static void |
writeCharsToFile(char[] chars,
File file,
String encoding)
Writes the characters to the specified file, encoded using the specified character set. |
static void |
writeObjectTo(Serializable object,
File file)
Deprecated. Use AbstractExternalizable.serializeTo(Serializable,File) instead. |
static void |
writeStringToFile(String s,
File file)
Deprecated. Use writeStringToFile(s,file,Strings.UTF8) instead. |
static void |
writeStringToFile(String s,
File file,
String encoding)
Writes the string to the specified file, encoded using the specified character set. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
@Deprecated public static final File TEMP_DIRECTORY
new
File(System.getProperty(TEMP_DIRECTORY_SYS_PROPERTY)) instead.
public static final FileFilter NON_CVS_DIRECTORY_FILE_FILTER
public static final FileFilter FILES_ONLY_FILE_FILTER
File.isFile().
| Method Detail |
|---|
public static void writeBytesToFile(byte[] bytes,
File file)
throws IOException
bytes - Bytes to write to file.file - File to which characters are written.
IOException - If there is an underlying I/O exception.
public static byte[] readBytesFromFile(File file)
throws IOException
file - File from which to read bytes.
IOException - If there is an underlying I/O exception.
public static void writeCharsToFile(char[] chars,
File file,
String encoding)
throws IOException
chars - Characters to write to file.file - File to which characters are written.encoding - Character encoding used by file.
IOException - If there is an underlying I/O exception.
@Deprecated
public static void writeCharsToFile(char[] chars,
File file)
throws IOException
writeCharsToFile(chars,file,Strings.UTF8) instead.
chars - Characters to write to file.file - File to which characters are written.
IOException - If there is an underlying I/O exception.
@Deprecated
public static void writeStringToFile(String s,
File file)
throws IOException
writeStringToFile(s,file,Strings.UTF8) instead.
s - String to write to file.file - File to which characters are written.
IOException - If there is an underlying I/O exception.
public static void writeStringToFile(String s,
File file,
String encoding)
throws IOException
s - String to write to file.file - File to which characters are written.encoding - Character set to use for encoding.
IOException - If there is an underlying I/O exception.
public static char[] readCharsFromFile(File file,
String encoding)
throws IOException
file - File from which to read input.encoding - Encoding to decode bytes in file.
IOException - If there is an underlying I/O exception.
UnsupportedEncodingException - If the encoding is not
supported.
IllegalArgumentException - If the file is longer than
the maximum integer value.
@Deprecated
public static char[] readCharsFromFile(File file)
throws IOException
readCharsFromFile(file,Strings.UTF8) instead.
file - File from which to read input.
IOException - If there is an underlying I/O exception.
public static String readFromFile(File file,
String encoding)
throws IOException
file - File from which to read input.encoding - Encoding to decode bytes in file.
IOException - If there is an underlying I/O exception.
UnsupportedEncodingException - If the encoding is not supported.
@Deprecated
public static String readFromFile(File file)
throws IOException
readFromFile(file,Strings.UTF8) instead.
file - File from which to read input.
IOException - If there is an underlying I/O exception.
@Deprecated
public static Object readObjectFrom(File file)
throws ClassNotFoundException,
IOException
com.aliasi.util.AbstractExteranlizable.readObject(File)
instead.
file - File from which to read object.
IOException - If there is an I/O error reading.
ClassNotFoundException - If the serialized object's class
is not on the classpath.
@Deprecated
public static void writeObjectTo(Serializable object,
File file)
throws IOException
AbstractExternalizable.serializeTo(Serializable,File) instead.
object - Object to write.file - File to which object is serialized.
IOException - If there is an underlying I/O error
writing.@Deprecated public static String prefix(String name)
baseName(File).
name - Name of file.
@Deprecated public static String suffix(String name)
extension(File).
name - Name of file.
public static String baseName(File file)
file - File whose name's prefix is returned.
public static String extension(File file)
null if there is no period in the name.
public static int removeRecursive(File file)
file - File or directory to remove.
public static int removeDescendants(File file)
file - File whose descendants are removed.
@Deprecated
public static File makeCleanDir(File directory,
String name)
java.io.File.
directory - Parent directory of directory to create.name - Name of directory to create.
@Deprecated public static File makeCleanDir(File file)
java.io.File.
file - File to create as a clean directory.
@Deprecated public static File createTempFile(String fileName)
java.io.File.createTempFile(String,String) instead.
TEMP_DIRECTORY. The file
will be deleted automicatically when the virtual machine exits.
fileName - Name of file to create.
@Deprecated
public static String fileToURLName(File file)
throws IOException
Files.fileToURLName(file) use
file.toURI().toURL().toString().
Warning: This method is deprecated because it does not properly escape illegal URL characters.
file - File to convert to string URL.
IOException - If there is an exception retrieving the
file's canonical path name.
@Deprecated
public static String[] readLinesFromFile(File file,
String encoding)
throws IOException
FileLineReader.readLineArray(File,String) instead.
file - Name of file from which to read lines.encoding - Character set to use to read lines.
IOException - If there is an I/O exception opening,
closing, or reading from the file.
@Deprecated
public static Object serializeDeserialize(Serializable in)
throws ClassNotFoundException,
IOException
com.aliasi.util.AbstractExteranlizable.serializeDeserialize(Serializable) instead.
in - Object to serialize and then deserialize.
IOException - If there is an I/O error while reading or
writing.
ClassNotFoundException - If the class for the object
being restored cannot be found.
public static void copyFile(File from,
File to)
throws IOException
from - File from which to copy.to - File to which to copy.
IOException - If there is a read or write error.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||