public class TextFile
extends java.lang.Object
Sample:
textFile = new TextFile("Xy.txt");
String temp;
while ((temp = textFile.readLine()) != null) {
list.addItem(temp);
}
DataTextObject
,
DataTextObjectWithDelimiter
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENCODING_ANSI |
static java.lang.String |
ENCODING_ASCII |
static java.lang.String |
ENCODING_UNICODE |
static java.lang.String |
ENCODING_UTF8 |
static int |
OPENING_FROM_CLASS_LOADER |
static int |
OPENING_FROM_CURRENT_DIRECTORY |
static java.lang.String |
validChars |
Constructor and Description |
---|
TextFile(java.io.InputStreamReader isr) |
TextFile(java.lang.String fileName)
Constructs a new text file object and opens the file as specified searching in the path.
|
TextFile(java.lang.String fileName,
int openingFrom)
Constructs a new text file object and opens the file as specified searching as specified in openingForm.
|
TextFile(java.lang.String fileName,
java.lang.String encoding)
Constructs a new text file object and opens the file as specified searching in the path.
|
TextFile(java.lang.String fileName,
java.lang.String encoding,
int openingFrom)
Constructs a new text file object and opens the file as specified searching as specified in openingForm.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the text file.
|
void |
delete()
Delete the text file after closing it.
|
protected void |
finalize() |
java.lang.String |
getFilePath()
Returns the absolute file path of a file previously accessed by class loader.
|
java.lang.String |
getLine()
Return the line as previously read by nextLine().
|
java.lang.String |
getOpenResultText()
Returns the open result text which is "" if everything is OK.
|
boolean |
isOpen()
Returns true if the file is open.
|
boolean |
lineContainsNonTextData()
Returns true if line contains not-text-data.
|
boolean |
nextLine()
Reads the next line and buffers it to be fetched by getLine.
|
java.lang.String |
readLine()
Reads the next line and returns its value, which is null in EOF case.
|
void |
StartFromBeginning()
Causes the sequential read to restart from beginning.
|
public static final java.lang.String validChars
public static final java.lang.String ENCODING_ANSI
public static final java.lang.String ENCODING_ASCII
public static final java.lang.String ENCODING_UTF8
public static final java.lang.String ENCODING_UNICODE
public static final int OPENING_FROM_CURRENT_DIRECTORY
public static final int OPENING_FROM_CLASS_LOADER
public TextFile(java.lang.String fileName)
fileName
- the name of the file to usepublic TextFile(java.lang.String fileName, java.lang.String encoding)
fileName
- the name of the file to useencoding
- the encoding typeENCODING_ASCII
public TextFile(java.lang.String fileName, int openingFrom)
fileName
- the name of the file to useopeningFrom
- the reference type from which directory the file to open is referencedENCODING_ASCII
public TextFile(java.lang.String fileName, java.lang.String encoding, int openingFrom)
fileName
- the name of the file to useencoding
- the encoding typeopeningFrom
- the reference type from which directory the file to open is referencedENCODING_ASCII
public TextFile(java.io.InputStreamReader isr)
public boolean isOpen()
public java.lang.String getOpenResultText()
public java.lang.String getFilePath()
public void StartFromBeginning()
public boolean nextLine()
public boolean lineContainsNonTextData()
public java.lang.String getLine()
nextLine()
public java.lang.String readLine()
public void close()
public void delete()
protected void finalize()
finalize
in class java.lang.Object
Copyright 1998-2023 Christoph Mueller, Kaerntner Str. 56, D-70469 Stuttgart, Germany, https://www.perpus.de