org.apache.jorphan.io

## Class TextFile

- java.lang.Object
- - java.io.File
  - - org.apache.jorphan.io.TextFile

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<java.io.File>

      public class TextFile
      extends java.io.File

  Utility class to handle text files as a single lump of text.

  Note this is just as memory-inefficient as handling a text file can be. Use with restraint.

  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class java.io.File

      `pathSeparator, pathSeparatorChar, separator, separatorChar`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TextFile(java.io.File filename)` Create a TextFile object to handle the named file with the platform default encoding.
    `TextFile(java.io.File filename, java.lang.String encoding)` Create a TextFile object to handle the named file with the given encoding.
    `TextFile(java.lang.String filename)` Create a TextFile object to handle the named file with the platform default encoding.
    `TextFile(java.lang.String filename, java.lang.String encoding)` Create a TextFile object to handle the named file with the given encoding.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)`
    `java.lang.String` | `getEncoding()`
    `java.lang.String` | `getText()` Read the whole file content and return it as a string.
    `int` | `hashCode()`
    `void` | `setEncoding(java.lang.String string)`
    `void` | `setText(java.lang.String body)` Create the file with the given string as content -- or replace its content with the given string if the file already existed.

    - ### Methods inherited from class java.io.File

      `canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TextFile

          public TextFile(java.io.File filename,
                          java.lang.String encoding)

      Create a TextFile object to handle the named file with the given encoding.
      Parameters:
        `filename` - File to be read and written through this object.
        `encoding` - Encoding to be used when reading and writing this file.

    - #### TextFile

          public TextFile(java.io.File filename)

      Create a TextFile object to handle the named file with the platform default encoding.
      Parameters:
        `filename` - File to be read and written through this object.

    - #### TextFile

          public TextFile(java.lang.String filename)

      Create a TextFile object to handle the named file with the platform default encoding.
      Parameters:
        `filename` - Name of the file to be read and written through this object.

    - #### TextFile

          public TextFile(java.lang.String filename,
                          java.lang.String encoding)

      Create a TextFile object to handle the named file with the given encoding.
      Parameters:
        `filename` - Name of the file to be read and written through this object.
        `encoding` - Encoding to be used when reading and writing this file.

  - ### Method Detail

    - #### setText

          public void setText(java.lang.String body)

      Create the file with the given string as content -- or replace its content with the given string if the file already existed.
      Parameters:
        `body` - New content for the file.

    - #### getText

          public java.lang.String getText()

      Read the whole file content and return it as a string.
      Returns:
        the content of the file

    - #### getEncoding

          public java.lang.String getEncoding()

      Returns:
        Encoding being used to read and write this file.

    - #### setEncoding

          public void setEncoding(java.lang.String string)

      Parameters:
        `string` - Encoding to be used to read and write this file.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.io.File`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.io.File`

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.