jtopenlite.com.ibm.jtopenlite.file.package-info Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400 Show documentation
Show all versions of jt400 Show documentation
The Open Source version of the IBM Toolbox for Java
/**
*
* Provides classes to access IFS files on an IBM i host.
*
*
* The {@link com.ibm.jtopenlite.file.FileConnection } class is used to establish
* a connection to the file server. A {@link com.ibm.jtopenlite.file.FileHandle} is used in conjunction with a
* connection to read and write the file.
* The following is a simple example of a program to
* create, read, and delete a file on the server.
*
*
import com.ibm.jtopenlite.file.*;
public class AccessIfsFile {
public static void main(String args[]) {
try {
String system = args[0];
String userid = args[1];
String password = args[2];
String filename = args[3];
FileConnection connection = FileConnection.getConnection(system,
userid, password);
FileHandle fhWrite = FileHandle.createEmptyHandle();
connection.openFile(filename, fhWrite);
byte[] stuff = "Hello world".getBytes("UTF-8");
connection.writeFile(fhWrite, stuff, 0, stuff.length, true);
connection.closeFile(fhWrite);
FileHandle fhRead = FileHandle.createEmptyHandle();
connection.openFile(filename, fhRead);
byte[] buffer = new byte[100];
int bytesRead = connection.readFile(fhRead, buffer, 0,
buffer.length);
connection.closeFile(fhRead);
String output = new String(buffer, 0, bytesRead, "UTF-8");
System.out.println("Read '" + output + "' from the file "
+ filename);
connection.deleteFile(filename);
System.out.println("File " + filename + " has been deleted");
} catch (Exception e) {
e.printStackTrace();
}
}
}
*/
package com.ibm.jtopenlite.file;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy