|
Hilbert II - Version 0.03.01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 |
closeReader(Reader reader)
Closes input reader without exception. |
static void |
closeStream(InputStream in)
Closes input stream without exception. |
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)
Delete file directory recursive. |
static void |
deleteLineLeadingWhitespace(StringBuffer buffer)
Search for first line followed by whitespace and delete this string within the whole text. |
static String |
getClassName(Class clazz)
Get non qualified class name. |
static StringBuffer |
getSpaces(int length)
Get amount of spaces. |
static File |
getUserHomeDirectory()
Get home directory of user. |
static boolean |
isLetterDigitString(String text)
Tests if given String begins with a letter and contains
only letters and digits. |
static void |
loadFile(File file,
StringBuffer buffer)
Reads contents of a file into a string buffer. |
static String |
loadFile(String filename)
Reads a file and returns the contents as a String . |
static void |
loadFile(String filename,
StringBuffer buffer)
Reads contents of a file into a string buffer. |
static void |
loadFile(URL url,
StringBuffer buffer)
Reads contents of a file into a string buffer. |
static byte[] |
loadFileBinary(File file)
Reads a file and returns the contents as a String . |
static void |
loadStream(InputStream in,
StringBuffer buffer)
Reads contents of a stream into a string buffer. |
static void |
printAllSystemProperties()
Print current system properties to System.out. |
static String |
quote(String unquoted)
Quotes a String . |
static void |
saveFile(File file,
String text)
Saves a String in a file. |
static void |
saveFile(File file,
StringBuffer text)
Saves a StringBuffer in a file. |
static void |
saveFile(String filename,
String text)
Saves a String into a file. |
static void |
saveFile(String filename,
StringBuffer text)
Saves a StringBuffer in a file. |
static void |
saveFileBinary(File file,
byte[] data)
Saves a String in a file. |
static Reader |
stringToReader(String data)
Convert String into a Reader .
|
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 loadFile(String filename) throws IOException
String
.
filename
- Name of the file (could include path).
IOException
- File exception occurred.public static void loadFile(String filename, StringBuffer buffer) throws IOException
filename
- Name of the file (could include path).buffer
- Buffer to fill with file contents.
IOException
- File exception occurred.public static void loadStream(InputStream in, StringBuffer buffer) throws IOException
in
- This stream will be loaded.buffer
- Buffer to fill with file contents.
IOException
- File exception occurred.public static void loadFile(File file, StringBuffer buffer) throws IOException
file
- This file will be loaded.buffer
- Buffer to fill with file contents.
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 file will be loaded.buffer
- Buffer to fill with file contents.
IOException
- Reading 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
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
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
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
String
in a file.
file
- File to save the data in.text
- Data to save in the file.
IOException
- File exception occurred.public static void saveFileBinary(File file, byte[] data) throws IOException
String
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 String quote(String unquoted)
String
. If no quotes exist in the
String
, a quote character is appended at the
beginning and the end of the String
.
unquoted
- the unquoted String
String
NullPointerException
- if unquoted == null
public static boolean isLetterDigitString(String text)
String
begins with a letter and contains
only letters and digits.
text
- test this
text
only made of letters and digits and has
a leading letter?
NullPointerException
- if text == null
public static boolean deleteDir(File directory)
directory
- Directory to delete.
public static StringBuffer getSpaces(int length)
length
- number of spaces
number
spacespublic static String getClassName(Class clazz)
clazz
- Class.
public static void printAllSystemProperties()
public static File getUserHomeDirectory()
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 closeStream(InputStream in)
in
- Input stream, maybe null
.public static void closeReader(Reader reader)
reader
- Reader, maybe null
.public static void deleteLineLeadingWhitespace(StringBuffer buffer)
For example the following text
Do you know the muffin man, The muffin man, the muffin man, Do you know the muffin man, Who lives on Drury Lane?will be converted into:
Do you know the muffin man, The muffin man, the muffin man, Do you know the muffin man, Who lives on Drury Lane?
buffer
- Work on this text.
|
Hilbert II - Version 0.03.01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
©left GNU General Public Licence All Rights Reserved. |