code: public void put(byte[] data, String remoteFileName, String remoteTargetDirectory, String mode) throws IOException {
          Session sess = null;
  
          if ((remoteFileName == null) || (remoteTargetDirectory == null) || (mode == null))
              throw new IllegalArgumentException("Null argument.");
  
          if (mode.length() != 4)
              throw new IllegalArgumentException("Invalid mode.");
  
          for (int i = 0; i < mode.length(); i++)
              if (Character.isDigit(mode.charAt(i)) == false)
                  throw new IllegalArgumentException("Invalid mode.");
  
          String cmd = "scp -t -d " + remoteTargetDirectory;
  
          try {
              sess = conn.openSession();
              sess.execCommand(cmd);
              sendBytes(sess, data, remoteFileName, mode);
              sess.close();
          } catch (IOException e) {
              if (sess != null)
                  sess.close();
              throw (IOException) new IOException("Error during SCP transfer.").initCause(e);
          }
      }
docs: Create a remote file and copy the contents of the passed byte array into it.
  The method use the specified mode when creating the file on the remote side.
  
  @param data                  the data to be copied into the remote file.
  @param remoteFileName        The name of the file which will be created in the remote target directory.
  @param remoteTargetDirectory Remote target directory.
  @param mode                  a four digit string (e.g., 0644, see "man chmod", "man open")
  @throws IOException