com.ibm.jtopenlite.file
Class FileConnection
- java.lang.Object
-
- com.ibm.jtopenlite.HostServerConnection
-
- com.ibm.jtopenlite.file.FileConnection
-
- All Implemented Interfaces:
- Connection
public class FileConnection extends HostServerConnection
Represents a TCP/IP socket connection to the System i File host server (QSERVER/QPWFSERVSO prestart jobs).
For an example, see
AccessIfsFile
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.jtopenlite.HostServerConnection
HostServerConnection.HostInputStream, HostServerConnection.HostOutputStream
-
-
Field Summary
Fields Modifier and Type Field and Description static int
DEFAULT_FILE_SERVER_PORT
static int
DEFAULT_SSL_FILE_SERVER_PORT
-
Fields inherited from class com.ibm.jtopenlite.HostServerConnection
in_, out_
-
-
Method Summary
Methods Modifier and Type Method and Description int
closeFile(FileHandle handle)
int
deleteFile(java.lang.String filename)
Deletes the specified file.static FileConnection
getConnection(boolean isSSL, java.lang.String system, java.lang.String user, java.lang.String password)
static FileConnection
getConnection(boolean isSSL, SystemInfo info, java.lang.String user, java.lang.String password)
static FileConnection
getConnection(boolean isSSL, SystemInfo info, java.lang.String user, java.lang.String password, int filePort)
static FileConnection
getConnection(java.lang.String system, java.lang.String user, java.lang.String password)
static FileConnection
getConnection(SystemInfo info, java.lang.String user, java.lang.String password)
static FileConnection
getConnection(SystemInfo info, java.lang.String user, java.lang.String password, int filePort)
java.util.List<java.lang.String>
list(java.lang.String dir)
Returns a list of filenames under the specified directory or file spec.java.util.List<FileHandle>
listFiles(java.lang.String dir)
Returns a list of files under the specified directory or file spec.int
openFile(java.lang.String filename, FileHandle buffer)
Opens a file for read-write access, a share option of SHARE_ALL, and a data CCSID of 1208 (UTF-8).int
openFile(java.lang.String filename, FileHandle buffer, int openType, int shareOption, boolean createIfNotExist, int dataCCSID)
int
readFile(FileHandle handle, byte[] buffer, int bufferOffset, int bufferLength)
protected void
sendEndJobRequest()
void
writeFile(FileHandle handle, byte[] buffer, int bufferOffset, int bufferLength, boolean sync)
Writes data to the file starting at the current file offset in the handle, and optionally sync-ing the data to disk; upon a successful write, the current file offset and size are incremented.-
Methods inherited from class com.ibm.jtopenlite.HostServerConnection
close, connect, finalize, getBytesReceived, getBytesSent, getEncryptedPassword, getInfo, getJobName, getUser, isClosed, isDatastreamDebug, isDefaultDatastreamDebug, setDatastreamDebug, setDefaultDatastreamDebug, writePadEBCDIC, writePadEBCDIC10, writeStringToUnicodeBytes
-
-
-
-
Field Detail
-
DEFAULT_FILE_SERVER_PORT
public static final int DEFAULT_FILE_SERVER_PORT
- See Also:
- Constant Field Values
-
DEFAULT_SSL_FILE_SERVER_PORT
public static final int DEFAULT_SSL_FILE_SERVER_PORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
sendEndJobRequest
protected void sendEndJobRequest() throws java.io.IOException
- Specified by:
sendEndJobRequest
in classHostServerConnection
- Throws:
java.io.IOException
-
getConnection
public static FileConnection getConnection(java.lang.String system, java.lang.String user, java.lang.String password) throws java.io.IOException
- Throws:
java.io.IOException
-
getConnection
public static FileConnection getConnection(boolean isSSL, java.lang.String system, java.lang.String user, java.lang.String password) throws java.io.IOException
- Throws:
java.io.IOException
-
getConnection
public static FileConnection getConnection(SystemInfo info, java.lang.String user, java.lang.String password) throws java.io.IOException
- Throws:
java.io.IOException
-
getConnection
public static FileConnection getConnection(boolean isSSL, SystemInfo info, java.lang.String user, java.lang.String password) throws java.io.IOException
- Throws:
java.io.IOException
-
getConnection
public static FileConnection getConnection(SystemInfo info, java.lang.String user, java.lang.String password, int filePort) throws java.io.IOException
- Throws:
java.io.IOException
-
getConnection
public static FileConnection getConnection(boolean isSSL, SystemInfo info, java.lang.String user, java.lang.String password, int filePort) throws java.io.IOException
- Throws:
java.io.IOException
-
listFiles
public java.util.List<FileHandle> listFiles(java.lang.String dir) throws java.io.IOException
Returns a list of files under the specified directory or file spec. For example, these all return the same file listing:- list("/home/smith")
- list("/home/smith/*")
- list("/home/smith/../smith")
- Throws:
java.io.IOException
-
list
public java.util.List<java.lang.String> list(java.lang.String dir) throws java.io.IOException
Returns a list of filenames under the specified directory or file spec. For example, these all return the same file listing:- list("/home/smith")
- list("/home/smith/*")
- list("/home/smith/../smith")
listFiles()
.- Throws:
java.io.IOException
-
deleteFile
public int deleteFile(java.lang.String filename) throws java.io.IOException
Deletes the specified file.- Throws:
java.io.IOException
-
openFile
public int openFile(java.lang.String filename, FileHandle buffer) throws java.io.IOException
Opens a file for read-write access, a share option of SHARE_ALL, and a data CCSID of 1208 (UTF-8).- Throws:
java.io.IOException
-
openFile
public int openFile(java.lang.String filename, FileHandle buffer, int openType, int shareOption, boolean createIfNotExist, int dataCCSID) throws java.io.IOException
- Throws:
java.io.IOException
-
closeFile
public int closeFile(FileHandle handle) throws java.io.IOException
- Throws:
java.io.IOException
-
readFile
public int readFile(FileHandle handle, byte[] buffer, int bufferOffset, int bufferLength) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFile
public void writeFile(FileHandle handle, byte[] buffer, int bufferOffset, int bufferLength, boolean sync) throws java.io.IOException
Writes data to the file starting at the current file offset in the handle, and optionally sync-ing the data to disk; upon a successful write, the current file offset and size are incremented.- Throws:
java.io.IOException
-
-