Class TextFile

java.lang.Object
java.io.File
org.japprove.files.TextFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.io.File>

public class TextFile
extends java.io.File
An extension of an File that provides functionality to read and write data of TextFile.
See Also:
Serialized Form
  • Field Summary

    Fields inherited from class java.io.File

    pathSeparator, pathSeparatorChar, separator, separatorChar
  • Constructor Summary

    Constructors 
    Constructor Description
    TextFile​(java.lang.String path)  
  • Method Summary

    Modifier and Type Method Description
    void create()
    Checks if the File already exists and creates a new one if not.
    java.lang.String readData()
    Reads the data of the TextFile line by line.
    void writeData​(java.lang.String data)
    Stores a String in the TextFile.

    Methods inherited from class java.io.File

    canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, 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 Details

    • TextFile

      public TextFile​(java.lang.String path)
  • Method Details

    • writeData

      public void writeData​(java.lang.String data) throws java.io.FileNotFoundException
      Stores a String in the TextFile.
      Parameters:
      data - the String that should be stored
      Throws:
      java.io.FileNotFoundException - thrown if the file not exists
    • readData

      public java.lang.String readData() throws java.io.IOException
      Reads the data of the TextFile line by line.
      Returns:
      the content of the TextFile in a list
      Throws:
      java.io.IOException - thrown if the file cannot be created
    • create

      public void create() throws FileCreationFailedException
      Checks if the File already exists and creates a new one if not.
      Throws:
      FileCreationFailedException - thrown if the file cannot be created