|
Hilbert II - Version 0.03.09 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.qedeq.kernel.utility.IoUtility
A collection of useful static methods for input and output. LATER mime 20070101: use StringBuilder instead of StringBuffer if working under JDK 1.5
| Method Summary | |
static void |
close(InputStream in)
Closes input stream without exception. |
static void |
close(Reader reader)
Closes input reader without exception. |
static boolean |
compareFilesBinary(File from,
File with)
Compare two files. |
static void |
copyFile(File from,
File to)
Copies a file to a different location. |
static void |
createNecessaryDirectories(File file)
Creates necessary parent directories for a file. |
static String |
createRelativePath(File orgin,
File next)
Create relative address from orgin to next. |
static boolean |
deleteDir(File directory,
boolean deleteDir)
Delete file directory recursive. |
static String |
getDefaultEncoding()
Get default encoding for this system. |
static Object |
getFieldContent(Object obj,
String name)
This method returns the contents of an object variable (even if it is private). |
static File |
getStartDirectory(String application)
Get start directory for application. |
static File |
getUserHomeDirectory()
Get home directory of user. |
static String |
getWorkingEncoding(String encoding)
Get working Java encoding. |
static boolean |
isWebStarted()
Was the application started by Java Webstart? |
static void |
loadFile(File file,
StringBuffer buffer)
Deprecated. Use loadFile(File, StringBuffer, String). |
static void |
loadFile(File file,
StringBuffer buffer,
String encoding)
Reads contents of a file into a string buffer. |
static String |
loadFile(String filename,
String encoding)
Reads a file and returns the contents as a String. |
static void |
loadFile(String filename,
StringBuffer buffer,
String encoding)
Reads contents of a file into a string buffer. |
static void |
loadFile(URL url,
StringBuffer buffer)
Deprecated. Choose correct encoding. |
static void |
loadFile(URL url,
StringBuffer buffer,
String encoding)
Reads contents of an URL into a string buffer. |
static byte[] |
loadFileBinary(File file)
Reads a file and returns the contents as a String. |
static Properties |
loadProperties(URL url)
Loads a property file from given URL. |
static void |
loadReader(Reader in,
StringBuffer buffer)
Reads contents of a Reader into a string buffer. |
static void |
loadStream(InputStream in,
StringBuffer buffer)
Deprecated. Use loadReader(Reader, StringBuffer). |
static void |
printAllSystemProperties()
Print current system properties to System.out. |
static void |
saveFile(File file,
String text)
Deprecated. Use saveFile(File, String, String) that has an encoding parameter. |
static void |
saveFile(File file,
StringBuffer text)
Deprecated. Use saveFile(File, StringBuffer, String) that has an encoding
parameter. |
static void |
saveFile(File file,
StringBuffer text,
String encoding)
Saves a String in a file. |
static void |
saveFile(File file,
String text,
String encoding)
Saves a String in a file. |
static void |
saveFile(String filename,
String text)
Deprecated. Use saveFile(File, String, String) that has an encoding. |
static void |
saveFile(String filename,
StringBuffer text)
Deprecated. Use saveFile(File, StringBuffer, String) that has an encoding. |
static void |
saveFileBinary(File file,
byte[] data)
Saves a data in a file. |
static void |
saveFileBinary(URL url,
File file)
Save binary contents of an URL into a file. |
static void |
setFieldContent(Object obj,
String name,
Object value)
This method sets the contents of an object variable (even if it is private). |
static Reader |
stringToReader(String data)
Convert String into a Reader.
|
static URL |
toUrl(File file)
Convert file in URL. |
static void |
waitln()
Waits until a '\n' was read from System.in. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static String getDefaultEncoding()
public static String getWorkingEncoding(String encoding)
encoding - Try this encoding.
encoding if it is supported. Or an other
encoding that is supported by this system.
public static String loadFile(String filename,
String encoding)
throws IOException
String.
filename - Name of the file (could include path).encoding - Take this encoding.
IOException - File exception occurred.
public static void loadFile(String filename,
StringBuffer buffer,
String encoding)
throws IOException
filename - Name of the file (could include path).buffer - Buffer to fill with file contents.encoding - Take this encoding.
IOException - File exception occurred.
public static void loadStream(InputStream in,
StringBuffer buffer)
throws IOException
loadReader(Reader, StringBuffer).
in - This stream will be loaded.buffer - Buffer to fill with file contents.
IOException - File exception occurred.
public static void loadReader(Reader in,
StringBuffer buffer)
throws IOException
Reader into a string buffer.
in - This reader will be loaded.buffer - Buffer to fill with file contents.
IOException - File exception occurred.
public static void loadFile(File file,
StringBuffer buffer)
throws IOException
loadFile(File, StringBuffer, String).
file - This file will be loaded.buffer - Buffer to fill with file contents.
IOException - File exception occurred.
public static void loadFile(File file,
StringBuffer buffer,
String encoding)
throws IOException
file - This file will be loaded.buffer - Buffer to fill with file contents.encoding - Take this encoding.
IOException - File exception occurred.
public static final byte[] loadFileBinary(File file)
throws IOException
String.
file - File to load from.
IOException - File exception occurred.
public static void loadFile(URL url,
StringBuffer buffer)
throws IOException
url - This URL will be loaded.buffer - Buffer to fill with file contents.
IOException - Reading failed.
public static void loadFile(URL url,
StringBuffer buffer,
String encoding)
throws IOException
url - This URL will be loaded.buffer - Buffer to fill with file contents.encoding - Take this encoding.
IOException - Reading failed.
public static void saveFileBinary(URL url,
File file)
throws IOException
url - This URL will be loaded.file - Write into this file.
IOException - Reading or writing failed.public static final Reader stringToReader(String data)
Reader.
Bug ID: 4094886
data - Convert this.
public static void saveFile(String filename,
String text)
throws IOException
saveFile(File, String, String) that has an encoding.
String into a file.
filename - Name of the file (could include path).text - Data to save in the file.
IOException - File exception occurred.
public static void saveFile(String filename,
StringBuffer text)
throws IOException
saveFile(File, StringBuffer, String) that has an encoding.
StringBuffer in a file.
filename - Name of the file (could include path).text - Data to save in the file.
IOException - File exception occurred.
public static void saveFile(File file,
StringBuffer text)
throws IOException
saveFile(File, StringBuffer, String) that has an encoding
parameter.
StringBuffer in a file.
file - File to save into.text - Data to save in the file.
IOException - File exception occurred.
public static void saveFile(File file,
String text)
throws IOException
saveFile(File, String, String) that has an encoding parameter.
String in a file. Uses default encoding.
file - File to save the data in.text - Data to save in the file.
IOException - File exception occurred.
public static void saveFile(File file,
StringBuffer text,
String encoding)
throws IOException
String in a file.
file - File to save the data in.text - Data to save in the file.encoding - Use this encoding.
IOException - File exception occurred.
public static void saveFile(File file,
String text,
String encoding)
throws IOException
String in a file.
file - File to save the data in.text - Data to save in the file.encoding - Use this encoding.
IOException - File exception occurred.
public static void saveFileBinary(File file,
byte[] data)
throws IOException
data in a file.
file - File to save the data in.data - Data to save in the file.
IOException - File exception occurred.
public static void copyFile(File from,
File to)
throws IOException
from - Copy source.to - Copy destination.
IOException - File exception occurred.
public static boolean compareFilesBinary(File from,
File with)
throws IOException
from - Compare source.with - Compare with this file.
IOException - File exception occurred.
public static boolean deleteDir(File directory,
boolean deleteDir)
directory - Directory to delete.deleteDir - Delete directory itself too?
public static void printAllSystemProperties()
public static File getUserHomeDirectory()
public static URL toUrl(File file)
file - File.
public static void createNecessaryDirectories(File file)
file - File.
public static final String createRelativePath(File orgin,
File next)
orgin to next.
orgin - this is the original locationnext - this should be the next location
public static void waitln()
public static void close(InputStream in)
in - Input stream, maybe null.public static void close(Reader reader)
reader - Reader, maybe null.public static final File getStartDirectory(String application)
new File(".").
application - Application name, used for Java Webstart version. Should
be written in lowercase letters. A "." is automatically appended at
the beginning.
public static final boolean isWebStarted()
public static Properties loadProperties(URL url)
throws IOException
url - URL to load properties from.
MalformedURLException - Invalid URL.
IOException - Reading error.
public static Object getFieldContent(Object obj,
String name)
obj - Object.name - Variable name
public static void setFieldContent(Object obj,
String name,
Object value)
obj - Object.name - Variable name.value - Value to set.
|
Hilbert II - Version 0.03.09 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
| ©left GNU General Public Licence All Rights Reserved. |