Examples of IFSFileOutputStream


Examples of com.ibm.as400.access.IFSFileOutputStream

      String targetName) throws XException
  {
    byte[] buffer = new byte[1024 * 64];

    IFSFileInputStream source = null;
    IFSFileOutputStream target = null;
    try
    {
      // Open the source file for exclusive access.
      source = new IFSFileInputStream(as400System, sourceName,
          IFSFileInputStream.SHARE_NONE);

      IFSFile targetFile = new IFSFile(as400System, targetName);
      if (!targetFile.exists())
      {
        targetFile.createNewFile();
      } // if (!targetFile.exists())

      // Open the target file for exclusive access.
      target = new IFSFileOutputStream(as400System, targetName,
          IFSFileOutputStream.SHARE_NONE, false);

      // Read the first 64K bytes from the source file.
      int bytesRead = source.read(buffer);

      // While there is data in the source file copy the data from
      // the source file to the target file.
      while (bytesRead > 0)
      {
        target.write(buffer, 0, bytesRead);
        bytesRead = source.read(buffer);
      }

      // Clean up by closing the source and target file.
      source.close();
      target.close();
    } // try
    catch (Exception e)
    {
      // If any of the above operations failed trace error
      // and output the exception.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.