當前位置: 首頁>>代碼示例>>Java>>正文


Java FTPReply.isPositivePreliminary方法代碼示例

本文整理匯總了Java中org.apache.commons.net.ftp.FTPReply.isPositivePreliminary方法的典型用法代碼示例。如果您正苦於以下問題:Java FTPReply.isPositivePreliminary方法的具體用法?Java FTPReply.isPositivePreliminary怎麽用?Java FTPReply.isPositivePreliminary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.net.ftp.FTPReply的用法示例。


在下文中一共展示了FTPReply.isPositivePreliminary方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: open

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
@Override
public FSDataInputStream open(Path file, int bufferSize) throws IOException {
  FTPClient client = connect();
  Path workDir = new Path(client.printWorkingDirectory());
  Path absolute = makeAbsolute(workDir, file);
  FileStatus fileStat = getFileStatus(client, absolute);
  if (fileStat.isDirectory()) {
    disconnect(client);
    throw new FileNotFoundException("Path " + file + " is a directory.");
  }
  client.allocate(bufferSize);
  Path parent = absolute.getParent();
  // Change to parent directory on the
  // server. Only then can we read the
  // file
  // on the server by opening up an InputStream. As a side effect the working
  // directory on the server is changed to the parent directory of the file.
  // The FTP client connection is closed when close() is called on the
  // FSDataInputStream.
  client.changeWorkingDirectory(parent.toUri().getPath());
  InputStream is = client.retrieveFileStream(file.getName());
  FSDataInputStream fis = new FSDataInputStream(new FTPInputStream(is,
      client, statistics));
  if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
    // The ftpClient is an inconsistent state. Must close the stream
    // which in turn will logout and disconnect from FTP server
    fis.close();
    throw new IOException("Unable to open file: " + file + ", Aborting");
  }
  return fis;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:32,代碼來源:FTPFileSystem.java

示例2: assertValidReplyCode

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
/***********************************************************************/
private static void assertValidReplyCode(int code, FTPClient ftp)
{
  if (FTPReply.isPositiveCompletion(code))
  {
    //good
    SimpleLogger.variable("Good Completion code " + code);
  }
  else if (FTPReply.isPositiveIntermediate(code))
  {
    // do nothing
    SimpleLogger.variable("Good Intermediate code " + code);
  }
  else if (FTPReply.isPositivePreliminary(code))
  {
    // do nothing
    SimpleLogger.variable("Good Preliminary code " + code);
  }
  else
  {
    // bad
    throw new Error("Problem encountered with FTP Server, returned Code " + code + ", replied '"
        + ftp.getReplyString() + "'");
  }
}
 
開發者ID:approvals,項目名稱:ApprovalTests.Java,代碼行數:26,代碼來源:NetUtils.java

示例3: _openDataConnection_

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
protected Socket _openDataConnection_(String command, String arg) throws IOException {
   if(this.getDataConnectionMode() != 2) {
      throw new IllegalStateException("Only passive connection mode supported");
   } else {
      boolean isInet6Address = this.getRemoteAddress() instanceof Inet6Address;
      boolean attemptEPSV = this.isUseEPSVwithIPv4() || isInet6Address;
      if(attemptEPSV && this.epsv() == 229) {
         this._parseExtendedPassiveModeReply((String)this._replyLines.get(0));
      } else {
         if(isInet6Address) {
            return null;
         }

         if(this.pasv() != 227) {
            return null;
         }

         this._parsePassiveModeReply((String)this._replyLines.get(0));
      }

      Socket socket = new Socket(this.proxyHost, this.proxyPort);
      InputStream is = socket.getInputStream();
      OutputStream os = socket.getOutputStream();
      this.tunnelHandshake(this.getPassiveHost(), this.getPassivePort(), is, os);
      if(this.getRestartOffset() > 0L && !this.restart(this.getRestartOffset())) {
         socket.close();
         return null;
      } else if(!FTPReply.isPositivePreliminary(this.sendCommand(command, arg))) {
         socket.close();
         return null;
      } else {
         return socket;
      }
   }
}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:36,代碼來源:FTPHTTPClient.java

示例4: reinitialize

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
boolean reinitialize() throws IOException {
   this.rein();
   if(!FTPReply.isPositiveCompletion(this._replyCode) && (!FTPReply.isPositivePreliminary(this._replyCode) || !FTPReply.isPositiveCompletion(this.getReply()))) {
      return false;
   } else {
      this.__initDefaults();
      return true;
   }
}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:10,代碼來源:FTPClient.java

示例5: _connectAction_

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
protected void _connectAction_() throws IOException {
   super._connectAction_();
   this._controlInput_ = new CRLFLineReader(new InputStreamReader(this._input_, this.getControlEncoding()));
   this._controlOutput_ = new BufferedWriter(new OutputStreamWriter(this._output_, this.getControlEncoding()));
   if(this.connectTimeout > 0) {
      int original = this._socket_.getSoTimeout();
      this._socket_.setSoTimeout(this.connectTimeout);

      try {
         this.__getReply();
         if(FTPReply.isPositivePreliminary(this._replyCode)) {
            this.__getReply();
         }
      } catch (SocketTimeoutException var7) {
         IOException ioe = new IOException("Timed out waiting for initial connect reply");
         ioe.initCause(var7);
         throw ioe;
      } finally {
         this._socket_.setSoTimeout(original);
      }
   } else {
      this.__getReply();
      if(FTPReply.isPositivePreliminary(this._replyCode)) {
         this.__getReply();
      }
   }

}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:29,代碼來源:FTP.java

示例6: open

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
@Override
public FSDataInputStream open(Path file, int bufferSize) throws IOException {
  FTPClient client = connect();
  Path workDir = new Path(client.printWorkingDirectory());
  Path absolute = makeAbsolute(workDir, file);
  FileStatus fileStat = getFileStatus(client, absolute);
  if (fileStat.isDir()) {
    disconnect(client);
    throw new IOException("Path " + file + " is a directory.");
  }
  client.allocate(bufferSize);
  Path parent = absolute.getParent();
  // Change to parent directory on the
  // server. Only then can we read the
  // file
  // on the server by opening up an InputStream. As a side effect the working
  // directory on the server is changed to the parent directory of the file.
  // The FTP client connection is closed when close() is called on the
  // FSDataInputStream.
  client.changeWorkingDirectory(parent.toUri().getPath());
  InputStream is = client.retrieveFileStream(file.getName());
  FSDataInputStream fis = new FSDataInputStream(new FTPInputStream(is,
      client, statistics));
  if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
    // The ftpClient is an inconsistent state. Must close the stream
    // which in turn will logout and disconnect from FTP server
    fis.close();
    throw new IOException("Unable to open file: " + file + ", Aborting");
  }
  return fis;
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:32,代碼來源:FTPFileSystem.java

示例7: open

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
@Override
public FSDataInputStream open(Path file, int bufferSize) throws IOException {
  FTPClient client = connect();
  Path workDir = new Path(client.printWorkingDirectory());
  Path absolute = makeAbsolute(workDir, file);
  FileStatus fileStat = getFileStatus(client, absolute);
  if (fileStat.isDirectory()) {
    disconnect(client);
    throw new IOException("Path " + file + " is a directory.");
  }
  client.allocate(bufferSize);
  Path parent = absolute.getParent();
  // Change to parent directory on the
  // server. Only then can we read the
  // file
  // on the server by opening up an InputStream. As a side effect the working
  // directory on the server is changed to the parent directory of the file.
  // The FTP client connection is closed when close() is called on the
  // FSDataInputStream.
  client.changeWorkingDirectory(parent.toUri().getPath());
  InputStream is = client.retrieveFileStream(file.getName());
  FSDataInputStream fis = new FSDataInputStream(new FTPInputStream(is,
      client, statistics));
  if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
    // The ftpClient is an inconsistent state. Must close the stream
    // which in turn will logout and disconnect from FTP server
    fis.close();
    throw new IOException("Unable to open file: " + file + ", Aborting");
  }
  return fis;
}
 
開發者ID:ict-carch,項目名稱:hadoop-plus,代碼行數:32,代碼來源:FTPFileSystem.java

示例8: create

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
/**
 * A stream obtained via this call must be closed before using other APIs of
 * this class or else the invocation will block.
 */
@Override
public FSDataOutputStream create(Path file, FsPermission permission,
    boolean overwrite, int bufferSize, short replication, long blockSize,
    Progressable progress) throws IOException {
  final FTPClient client = connect();
  Path workDir = new Path(client.printWorkingDirectory());
  Path absolute = makeAbsolute(workDir, file);
  FileStatus status;
  try {
    status = getFileStatus(client, file);
  } catch (FileNotFoundException fnfe) {
    status = null;
  }
  if (status != null) {
    if (overwrite && !status.isDirectory()) {
      delete(client, file, false);
    } else {
      disconnect(client);
      throw new FileAlreadyExistsException("File already exists: " + file);
    }
  }
  
  Path parent = absolute.getParent();
  if (parent == null || !mkdirs(client, parent, FsPermission.getDirDefault())) {
    parent = (parent == null) ? new Path("/") : parent;
    disconnect(client);
    throw new IOException("create(): Mkdirs failed to create: " + parent);
  }
  client.allocate(bufferSize);
  // Change to parent directory on the server. Only then can we write to the
  // file on the server by opening up an OutputStream. As a side effect the
  // working directory on the server is changed to the parent directory of the
  // file. The FTP client connection is closed when close() is called on the
  // FSDataOutputStream.
  client.changeWorkingDirectory(parent.toUri().getPath());
  FSDataOutputStream fos = new FSDataOutputStream(client.storeFileStream(file
      .getName()), statistics) {
    @Override
    public void close() throws IOException {
      super.close();
      if (!client.isConnected()) {
        throw new FTPException("Client not connected");
      }
      boolean cmdCompleted = client.completePendingCommand();
      disconnect(client);
      if (!cmdCompleted) {
        throw new FTPException("Could not complete transfer, Reply Code - "
            + client.getReplyCode());
      }
    }
  };
  if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
    // The ftpClient is an inconsistent state. Must close the stream
    // which in turn will logout and disconnect from FTP server
    fos.close();
    throw new IOException("Unable to create file: " + file + ", Aborting");
  }
  return fos;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:64,代碼來源:FTPFileSystem.java

示例9: __openPassiveDataConnection

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
/**
 * open a passive data connection socket
 * 
 * @param command
 * @param arg
 * @return
 * @throws IOException
 * @throws FtpExceptionCanNotHaveDataConnection
 */
protected Socket __openPassiveDataConnection(int command, String arg)
    throws IOException, FtpExceptionCanNotHaveDataConnection {
  Socket socket;

  // // 20040317, xing, accommodate ill-behaved servers, see below
  // int port_previous = __passivePort;

  if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
    throw new FtpExceptionCanNotHaveDataConnection("pasv() failed. "
        + getReplyString());

  try {
    __parsePassiveModeReply(getReplyStrings()[0]);
  } catch (MalformedServerReplyException e) {
    throw new FtpExceptionCanNotHaveDataConnection(e.getMessage());
  }

  // // 20040317, xing, accommodate ill-behaved servers, see above
  // int count = 0;
  // System.err.println("__passivePort "+__passivePort);
  // System.err.println("port_previous "+port_previous);
  // while (__passivePort == port_previous) {
  // // just quit if too many tries. make it an exception here?
  // if (count++ > 10)
  // return null;
  // // slow down further for each new try
  // Thread.sleep(500*count);
  // if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
  // throw new FtpExceptionCanNotHaveDataConnection(
  // "pasv() failed. " + getReplyString());
  // //return null;
  // try {
  // __parsePassiveModeReply(getReplyStrings()[0]);
  // } catch (MalformedServerReplyException e) {
  // throw new FtpExceptionCanNotHaveDataConnection(e.getMessage());
  // }
  // }

  socket = _socketFactory_.createSocket(__passiveHost, __passivePort);

  if (!FTPReply.isPositivePreliminary(sendCommand(command, arg))) {
    socket.close();
    return null;
  }

  if (__remoteVerificationEnabled && !verifyRemote(socket)) {
    InetAddress host1, host2;

    host1 = socket.getInetAddress();
    host2 = getRemoteAddress();

    socket.close();

    // our precaution
    throw new FtpExceptionCanNotHaveDataConnection(
        "Host attempting data connection " + host1.getHostAddress()
            + " is not same as server " + host2.getHostAddress()
            + " So we intentionally close it for security precaution.");
  }

  if (__dataTimeout >= 0)
    socket.setSoTimeout(__dataTimeout);

  return socket;
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:75,代碼來源:Client.java

示例10: remoteRetrieve

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
public boolean remoteRetrieve(String filename) throws IOException {
   return this.__dataConnectionMode != 1 && this.__dataConnectionMode != 3?false:FTPReply.isPositivePreliminary(this.retr(filename));
}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:4,代碼來源:FTPClient.java

示例11: remoteStore

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
public boolean remoteStore(String filename) throws IOException {
   return this.__dataConnectionMode != 1 && this.__dataConnectionMode != 3?false:FTPReply.isPositivePreliminary(this.stor(filename));
}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:4,代碼來源:FTPClient.java

示例12: remoteStoreUnique

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
public boolean remoteStoreUnique(String filename) throws IOException {
   return this.__dataConnectionMode != 1 && this.__dataConnectionMode != 3?false:FTPReply.isPositivePreliminary(this.stou(filename));
}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:4,代碼來源:FTPClient.java

示例13: remoteAppend

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
public boolean remoteAppend(String filename) throws IOException {
   return this.__dataConnectionMode != 1 && this.__dataConnectionMode != 3?false:FTPReply.isPositivePreliminary(this.appe(filename));
}
 
開發者ID:Bolt-Thrower,項目名稱:xdm,代碼行數:4,代碼來源:FTPClient.java

示例14: create

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
/**
 * A stream obtained via this call must be closed before using other APIs of
 * this class or else the invocation will block.
 */
@Override
public FSDataOutputStream create(Path file, FsPermission permission,
    boolean overwrite, int bufferSize, short replication, long blockSize,
    Progressable progress) throws IOException {
  final FTPClient client = connect();
  Path workDir = new Path(client.printWorkingDirectory());
  Path absolute = makeAbsolute(workDir, file);
  if (exists(client, file)) {
    if (overwrite) {
      delete(client, file);
    } else {
      disconnect(client);
      throw new IOException("File already exists: " + file);
    }
  }
  Path parent = absolute.getParent();
  if (parent == null || !mkdirs(client, parent, FsPermission.getDefault())) {
    parent = (parent == null) ? new Path("/") : parent;
    disconnect(client);
    throw new IOException("create(): Mkdirs failed to create: " + parent);
  }
  client.allocate(bufferSize);
  // Change to parent directory on the server. Only then can we write to the
  // file on the server by opening up an OutputStream. As a side effect the
  // working directory on the server is changed to the parent directory of the
  // file. The FTP client connection is closed when close() is called on the
  // FSDataOutputStream.
  client.changeWorkingDirectory(parent.toUri().getPath());
  FSDataOutputStream fos = new FSDataOutputStream(client.storeFileStream(file
      .getName()), statistics) {
    @Override
    public void close() throws IOException {
      super.close();
      if (!client.isConnected()) {
        throw new FTPException("Client not connected");
      }
      boolean cmdCompleted = client.completePendingCommand();
      disconnect(client);
      if (!cmdCompleted) {
        throw new FTPException("Could not complete transfer, Reply Code - "
            + client.getReplyCode());
      }
    }
  };
  if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
    // The ftpClient is an inconsistent state. Must close the stream
    // which in turn will logout and disconnect from FTP server
    fos.close();
    throw new IOException("Unable to create file: " + file + ", Aborting");
  }
  return fos;
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:57,代碼來源:FTPFileSystem.java

示例15: create

import org.apache.commons.net.ftp.FTPReply; //導入方法依賴的package包/類
/**
 * A stream obtained via this call must be closed before using other APIs of
 * this class or else the invocation will block.
 */
@Override
public FSDataOutputStream create(Path file, FsPermission permission,
    boolean overwrite, int bufferSize, short replication, long blockSize,
    Progressable progress) throws IOException {
  final FTPClient client = connect();
  Path workDir = new Path(client.printWorkingDirectory());
  Path absolute = makeAbsolute(workDir, file);
  if (exists(client, file)) {
    if (overwrite) {
      delete(client, file);
    } else {
      disconnect(client);
      throw new IOException("File already exists: " + file);
    }
  }
  
  Path parent = absolute.getParent();
  if (parent == null || !mkdirs(client, parent, FsPermission.getDirDefault())) {
    parent = (parent == null) ? new Path("/") : parent;
    disconnect(client);
    throw new IOException("create(): Mkdirs failed to create: " + parent);
  }
  client.allocate(bufferSize);
  // Change to parent directory on the server. Only then can we write to the
  // file on the server by opening up an OutputStream. As a side effect the
  // working directory on the server is changed to the parent directory of the
  // file. The FTP client connection is closed when close() is called on the
  // FSDataOutputStream.
  client.changeWorkingDirectory(parent.toUri().getPath());
  FSDataOutputStream fos = new FSDataOutputStream(client.storeFileStream(file
      .getName()), statistics) {
    @Override
    public void close() throws IOException {
      super.close();
      if (!client.isConnected()) {
        throw new FTPException("Client not connected");
      }
      boolean cmdCompleted = client.completePendingCommand();
      disconnect(client);
      if (!cmdCompleted) {
        throw new FTPException("Could not complete transfer, Reply Code - "
            + client.getReplyCode());
      }
    }
  };
  if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
    // The ftpClient is an inconsistent state. Must close the stream
    // which in turn will logout and disconnect from FTP server
    fos.close();
    throw new IOException("Unable to create file: " + file + ", Aborting");
  }
  return fos;
}
 
開發者ID:ict-carch,項目名稱:hadoop-plus,代碼行數:58,代碼來源:FTPFileSystem.java


注:本文中的org.apache.commons.net.ftp.FTPReply.isPositivePreliminary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。