public class REXXFile extends Object
Constructor and Description |
---|
REXXFile(String filename)
Creates a REXXFile instance that represents the file
whose pathname is given as the path argument.
|
REXXFile(String filename,
boolean create)
Creates a REXXFile instance that represents the file
whose pathname is given as the path argument.
|
Modifier and Type | Method and Description |
---|---|
boolean |
close()
Closes the file.
|
String |
date()
Gets the last modified date of the file.
|
void |
dispose()
Disposes of the file (makes sure it's closed).
|
boolean |
exists()
Tests if the file exists.
|
long |
fileSize()
Checks the number of bytes that remain to be read.
|
String |
getException()
Gets the current file exception after an error.
|
String |
getPath()
Gets the real path for the file.
|
boolean |
isOpen()
Checks if the file is opened.
|
boolean |
isReadable()
Checks if the file is readable.
|
boolean |
isReadWrite()
Flag indicating the file is read- and writable.
|
boolean |
isWritable()
Checks if the file is writable.
|
long |
leftOver()
Returns the number of bytes after the current position to the
end of the file.
|
boolean |
open()
Opens the file for Read and/or Write
depending on R/W status of REXXFile.
|
boolean |
open(boolean create)
Opens the file.
|
long |
position()
Gets the current position in the stream.
|
String |
read(int length,
long position)
Read and codepage convert data from stream.
|
String |
readLine(long line,
long count)
Reads a line from the stream without the line separator.
|
boolean |
seek(long position)
Seek a position in a file.
|
void |
setException(String e)
Sets a string as the error for the exception.
|
long |
write(String data,
long position)
Writes a string of data to the requested position.
|
int |
writeLine(String data,
long line)
Writes a line a text to the stream.
|
public REXXFile(String filename, boolean create)
filename
- The file name and path.create
- Flag for creation of file if it does not exist.public REXXFile(String filename)
filename
- The file name and path.public void dispose()
public boolean exists()
public boolean isOpen()
public boolean isWritable()
public boolean isReadable()
public boolean isReadWrite()
public String getPath()
public boolean open(boolean create)
create
- if does not exist.public boolean open()
public boolean close()
public long fileSize()
public int writeLine(String data, long line)
data
- The data to write.line
- The line to write to, can be either 0L (zero) for current position,
or 1L to reset file and start writing the first line.public String readLine(long line, long count) throws IOException
line
- line in file to read, or 0L for current line.count
- Number of lines to read, 0L=no read, one or more lines to read,
last line read is returned.IOException
- Thrown if there is no more data to read as "NOTREADY" state.public String read(int length, long position) throws IOException
length
- Length to read (0 for a seek to position).position
- Offset to start reading data from stream.IOException
public boolean seek(long position) throws IOException
position
- offset to seek to (position<0 for current position).IOException
public long position() throws IOException
IOException
public long leftOver()
public long write(String data, long position) throws IOException
data
- Data to write.position
- Position in file to write to, ONE-based!IOException
public String date()
EEE, dd MMM yyyy HH:mm:ss 'GMT'
,
e.g. Sun, 21 Feb 2022 12:16:24 GMT
.public void setException(String e)
public String getException()
null
if no error has occurred, otherwise the error state.Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.