|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindprod.hunkio.HunkIO
public final class HunkIO
read/write a file in one large hunk.
Variants to read/write bytes, strings with default encoding and strings with specified encoding. No main method. We don't use java.nio.charset.Charset because it requires JDK 1.4+. See also the more elaborate filetransfer package.
com.mindprod.common11.Localise.localise(String)
Method Summary | |
---|---|
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File near)
Create a temporary file, Slightly smarter version of File.createTempFile |
static void |
main(java.lang.String[] args)
debugging harness for HunkIO. |
static byte[] |
rawReadEntireFile(java.io.File fromFile)
read file of bytes without conversion |
static byte[] |
rawReadEntireFile(java.lang.String fromFile)
read file of bytes without conversion. |
static java.lang.String |
readEntireFile(java.io.File fromFile)
Get all text in a file. |
static java.lang.String |
readEntireFile(java.io.File fromFile,
java.lang.String encoding)
Get all text in a file. |
static java.lang.String |
readEntireFile(java.lang.String fromFile)
Get all text in a file. |
static java.lang.String |
readEntireFile(java.lang.String fromFile,
java.lang.String encoding)
Get all text in a file. |
static void |
writeEntireFile(java.io.File toFile,
java.lang.String text)
Write all the text in a file |
static void |
writeEntireFile(java.io.File toFile,
java.lang.String text,
java.lang.String encoding)
Write all the text in a file |
static void |
writeEntireFile(java.lang.String toFile,
java.lang.String text)
Write all the text in a file |
static void |
writeEntireFile(java.lang.String toFile,
java.lang.String text,
java.lang.String encoding)
Write all the text in a file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File near) throws java.io.IOException
prefix
- beginning letters of filenamesuffix
- ending letters of filename. e.g. ".temp". null means ".tmp"near
- directory where to put file, or file to place this temp file near in the same directory. null means
put the temp file in the current directory.
java.io.IOException
- when cannot create file.public static byte[] rawReadEntireFile(java.lang.String fromFile) throws java.io.IOException
fromFile
- file to read.
java.io.IOException
- when cannot access file.public static byte[] rawReadEntireFile(java.io.File fromFile) throws java.io.IOException
fromFile
- file to read
java.io.IOException
- when cannot access file.public static java.lang.String readEntireFile(java.io.File fromFile) throws java.io.IOException
fromFile
- file where to get the text.
java.io.IOException
- when cannot access file.public static java.lang.String readEntireFile(java.lang.String fromFile) throws java.io.IOException
fromFile
- Name of file where to get the text.
java.io.IOException
- when cannot access file.public static java.lang.String readEntireFile(java.io.File fromFile, java.lang.String encoding) throws java.io.IOException
fromFile
- file where to get the text.encoding
- name of the encoding to use to translate the bytes in the file into chars e.g. "windows-1252"
"UTF-8" "UTF-16"
java.io.IOException
- when cannot access file.public static java.lang.String readEntireFile(java.lang.String fromFile, java.lang.String encoding) throws java.io.IOException
fromFile
- Name of file where to get the text.encoding
- name of the encoding to use to translate the bytes in the file into chars e.g. "windows-1252"
"UTF-8" "UTF-16"
java.io.IOException
- when cannot access file.public static void writeEntireFile(java.io.File toFile, java.lang.String text) throws java.io.IOException
toFile
- file where to write the texttext
- Text to write
java.io.IOException
- when cannot access file.public static void writeEntireFile(java.lang.String toFile, java.lang.String text) throws java.io.IOException
toFile
- Name of file where to write the texttext
- Text to write
java.io.IOException
- when cannot access file.public static void writeEntireFile(java.io.File toFile, java.lang.String text, java.lang.String encoding) throws java.io.IOException
toFile
- file where to write the text, embedded line endings will be left as is.text
- Text to writeencoding
- name of the encoding to use to translate chars to bytes e.g. "windows-1252" "UTF-8" "UTF-16"
java.io.IOException
- when cannot access file.
java.io.UnsupportedEncodingException
- If the named encoding is not supportedpublic static void writeEntireFile(java.lang.String toFile, java.lang.String text, java.lang.String encoding) throws java.io.IOException
toFile
- file where to write the texttext
- Text to writeencoding
- name of the encoding to use to translate chars to bytes e.g. "windows-1252" "UTF-8" "UTF-16"
java.io.IOException
- when cannot access file.
java.io.UnsupportedEncodingException
- If the named encoding is not supportedpublic static void main(java.lang.String[] args)
args
- not used.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |