UserSpace 类

UserSpace 类表示服务器上的用户空间。 必需参数是用户空间的名称以及表示具有用户空间的服务器的 AS400 对象。

用户空间类中存在用于执行以下操作的方法:
  • 创建用户空间。
  • 删除用户空间。
  • 从用户空间读取。
  • 写入用户空间。
  • 获取用户空间的属性。 Java™ 程序可以获取用户空间的初始值,长度值和自动可扩展属性。
  • 设置用户空间的属性。 Java 程序可以设置用户空间的初始值,长度值和自动可扩展属性。

UserSpace 对象需要程序的集成文件系统路径名。 有关更多信息,请参阅 集成文件系统路径名

使用 UserSpace 类会导致 AS400 对象连接到服务器。 有关管理连接的信息,请参阅 管理连接

以下示例创建用户空间,然后将数据写入其中。
注: 请阅读 代码示例免责声明 以获取重要的法律信息。
     // Create an AS400 object.
     AS400 sys = new AS400("mySystem.myCompany.com");

     // Create a user space object.  
     UserSpace US = new UserSpace(sys, 
               "/QSYS.LIB/MYLIB.LIB/MYSPACE.USRSPC");

     // Use the create method to create the user space on
     // the server.              
     US.create(10240,                           // The initial size is 10KB
               true,                            // Replace if the user space already exists
               " ",                             // No extended attribute
               (byte) 0x00,                     // The initial value is a null
               "Created by a Java program",     // The description of the user space
               "*USE");                         // Public has use authority to the user space
                                                  
                       
     // Use the write method to write bytes to the user space.
     US.write("Write this string to the user space.", 0);