Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindprod.hunkio
Class HunkIO

    java.lang.Object
      com.mindprod.hunkio.HunkIO

    public final class HunkIO

extends java.lang.Object

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.

Since:
  2002-07-12
Version:
  1.7 2009-05-03 - create PrintWriterPlus vs PrintWriterPortable
Author:
  Roedy Green, Canadian Mind Products

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

### createTempFile

    public static java.io.File createTempFile(java.lang.String prefix,
                                              java.lang.String suffix,
                                              java.io.File near)
                                       throws java.io.IOException

  Create a temporary file, Slightly smarter version of File.createTempFile

  Parameters:
    `prefix` - beginning letters of filename
    `suffix` - 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.
  Returns:
    A temporary file. It will not automatically delete on program completion, however.
  Throws:
    `java.io.IOException` - when cannot create file.

### rawReadEntireFile

    public static byte[] rawReadEntireFile(java.lang.String fromFile)
                                    throws java.io.IOException

  read file of bytes without conversion.

  Parameters:
    `fromFile` - file to read.
  Returns:
    byte array representing whole file.
  Throws:
    `java.io.IOException` - when cannot access file.

### rawReadEntireFile

    public static byte[] rawReadEntireFile(java.io.File fromFile)
                                    throws java.io.IOException

  read file of bytes without conversion

  Parameters:
    `fromFile` - file to read
  Returns:
    byte array representing whole file
  Throws:
    `java.io.IOException` - when cannot access file.

### readEntireFile

    public static java.lang.String readEntireFile(java.io.File fromFile)
                                           throws java.io.IOException

  Get all text in a file.

  Parameters:
    `fromFile` - file where to get the text.
  Returns:
    all the text in the File.
  Throws:
    `java.io.IOException` - when cannot access file.

### readEntireFile

    public static java.lang.String readEntireFile(java.lang.String fromFile)
                                           throws java.io.IOException

  Get all text in a file.

  Parameters:
    `fromFile` - Name of file where to get the text.
  Returns:
    all the text in the File.
  Throws:
    `java.io.IOException` - when cannot access file.

### readEntireFile

    public static java.lang.String readEntireFile(java.io.File fromFile,
                                                  java.lang.String encoding)
                                           throws java.io.IOException

  Get all text in a file.

  Parameters:
    `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"
  Returns:
    all the text in the File.
  Throws:
    `java.io.IOException` - when cannot access file.

### readEntireFile

    public static java.lang.String readEntireFile(java.lang.String fromFile,
                                                  java.lang.String encoding)
                                           throws java.io.IOException

  Get all text in a file.

  Parameters:
    `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"
  Returns:
    all the text in the File.
  Throws:
    `java.io.IOException` - when cannot access file.

### writeEntireFile

    public static void writeEntireFile(java.io.File toFile,
                                       java.lang.String text)
                                throws java.io.IOException

  Write all the text in a file

  Parameters:
    `toFile` - file where to write the text
    `text` - Text to write
  Throws:
    `java.io.IOException` - when cannot access file.

### writeEntireFile

    public static void writeEntireFile(java.lang.String toFile,
                                       java.lang.String text)
                                throws java.io.IOException

  Write all the text in a file

  Parameters:
    `toFile` - Name of file where to write the text
    `text` - Text to write
  Throws:
    `java.io.IOException` - when cannot access file.

### writeEntireFile

    public static void writeEntireFile(java.io.File toFile,
                                       java.lang.String text,
                                       java.lang.String encoding)
                                throws java.io.IOException

  Write all the text in a file

  Parameters:
    `toFile` - file where to write the text
    `text` - Text to write
    `encoding` - name of the encoding to use to translate chars to bytes e.g. "windows-1252" "UTF-8" "UTF-16"
  Throws:
    `java.io.IOException` - when cannot access file.
    `java.io.UnsupportedEncodingException` - If the named encoding is not supported

### writeEntireFile

    public static void writeEntireFile(java.lang.String toFile,
                                       java.lang.String text,
                                       java.lang.String encoding)
                                throws java.io.IOException

  Write all the text in a file

  Parameters:
    `toFile` - file where to write the text
    `text` - Text to write
    `encoding` - name of the encoding to use to translate chars to bytes e.g. "windows-1252" "UTF-8" "UTF-16"
  Throws:
    `java.io.IOException` - when cannot access file.
    `java.io.UnsupportedEncodingException` - If the named encoding is not supported

### main

    public static void main(java.lang.String[] args)

  debugging harness for HunkIO.

  Parameters:
    `args` - not used.

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD