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);