Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.jorphan.io
Class TextFile  view TextFile download TextFile.java

java.lang.Object
  extended byjava.io.File
      extended byorg.apache.jorphan.io.TextFile
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

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.

Version:
$Revision: 1.10 $ updated on $Date: 2005/07/12 20:51:08 $

Field Summary
private  java.lang.String encoding
          File encoding.
private static Logger log
           
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
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
 java.lang.String getEncoding()
           
 java.lang.String getText()
          Read the whole file content and return it as a string.
 void setEncoding(java.lang.String string)
           
 void setText(java.lang.String body)
          Create the file with the given string as content -- or replace it's content with the given string if the file already existed.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static transient Logger log

encoding

private java.lang.String encoding
File encoding. null means use the platform's default.

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.


TextFile

public TextFile(java.io.File filename)
Create a TextFile object to handle the named file with the platform default encoding.


TextFile

public TextFile(java.lang.String filename)
Create a TextFile object to handle the named file with the platform default encoding.


TextFile

public TextFile(java.lang.String filename,
                java.lang.String encoding)
Create a TextFile object to handle the named file with the given encoding.

Method Detail

setText

public void setText(java.lang.String body)
Create the file with the given string as content -- or replace it's content with the given string if the file already existed.


getText

public java.lang.String getText()
Read the whole file content and return it as a string.


getEncoding

public java.lang.String getEncoding()

setEncoding

public void setEncoding(java.lang.String string)