FtpURLConnection
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using libcore.net.url.FtpURLConnection (Showing top 20 results out of 315)

origin: robovm/robovm

/**
 * Open a URLConnection on the given URL.
 */
@Override
protected URLConnection openConnection(URL u) throws IOException {
  return new FtpURLConnection(u);
}
origin: robovm/robovm

private void connectInternal() throws IOException {
  int port = url.getPort();
  int connectTimeout = getConnectTimeout();
  if (port <= 0) {
    port = FTP_PORT;
  ctrlOutput = controlSocket.getOutputStream();
  ctrlInput = controlSocket.getInputStream();
  login();
  setType();
  if (!getDoInput()) {
    cd();
    port();
    if (connectTimeout == 0) {
    acceptSocket.setSoTimeout(getConnectTimeout());
    if (getDoInput()) {
      getFile();
    } else {
      sendFile();
    dataSocket.setSoTimeout(getReadTimeout());
    acceptSocket.close();
  } catch (InterruptedIOException e) {
    throw new IOException("Could not establish data connection");
  if (getDoInput()) {
    inputStream = new FtpURLInputStream(
        new BufferedInputStream(dataSocket.getInputStream()), controlSocket);
origin: robovm/robovm

/**
 * Creates a input stream for writing to this URL Connection.
 *
 * @return The input stream to write to
 * @throws IOException
 *             Cannot read from URL or error creating InputStream
 *
 * @see #getContent()
 * @see #getOutputStream()
 * @see java.io.InputStream
 * @see java.io.IOException
 *
 */
@Override
public InputStream getInputStream() throws IOException {
  if (!connected) {
    connect();
  }
  return inputStream;
}
origin: robovm/robovm

/**
 * Set the type of the file transfer. Only Image is supported
 */
private void setType() throws IOException {
  write("TYPE I\r\n");
  if (getReply() != FTP_OK) {
    throw new IOException("Unable to set transfer type");
  }
}
origin: robovm/robovm

/**
 * Returns the content type of the resource. Just takes a guess based on the
 * name.
 */
@Override
public String getContentType() {
  String result = guessContentTypeFromName(url.getFile());
  if (result == null) {
    return "content/unknown";
  }
  return result;
}
origin: robovm/robovm

  connectInternal();
} else {
  ProxySelector selector = ProxySelector.getDefault();
    currentProxy = iter.next();
    try {
      connectInternal();
      connectOK = true;
    } catch (IOException ioe) {
origin: robovm/robovm

private void getFile() throws IOException {
  int reply;
  String file = url.getFile();
  write("RETR " + file + "\r\n");
  reply = getReply();
  if (reply == FTP_NOTFOUND && file.length() > 0 && file.charAt(0) == '/') {
    write("RETR " + file.substring(1) + "\r\n");
    reply = getReply();
  }
  if (!(reply == FTP_OPENDATA || reply == FTP_TRANSFEROK)) {
    throw new FileNotFoundException("Unable to retrieve file: " + reply);
  }
}
origin: MobiVM/robovm

/**
 * Returns the content type of the resource. Just takes a guess based on the
 * name.
 */
@Override
public String getContentType() {
  String result = guessContentTypeFromName(url.getFile());
  if (result == null) {
    return "content/unknown";
  }
  return result;
}
origin: MobiVM/robovm

  connectInternal();
} else {
  ProxySelector selector = ProxySelector.getDefault();
    currentProxy = iter.next();
    try {
      connectInternal();
      connectOK = true;
    } catch (IOException ioe) {
origin: ibinti/bugvm

private void connectInternal() throws IOException {
  int port = url.getPort();
  int connectTimeout = getConnectTimeout();
  if (port <= 0) {
    port = FTP_PORT;
  ctrlOutput = controlSocket.getOutputStream();
  ctrlInput = controlSocket.getInputStream();
  login();
  setType();
  if (!getDoInput()) {
    cd();
    port();
    if (connectTimeout == 0) {
    acceptSocket.setSoTimeout(getConnectTimeout());
    if (getDoInput()) {
      getFile();
    } else {
      sendFile();
    dataSocket.setSoTimeout(getReadTimeout());
    acceptSocket.close();
  } catch (InterruptedIOException e) {
    throw new IOException("Could not establish data connection");
  if (getDoInput()) {
    inputStream = new FtpURLInputStream(
        new BufferedInputStream(dataSocket.getInputStream()), controlSocket);
origin: robovm/robovm

private void port() throws IOException {
  write("PORT "
      + controlSocket.getLocalAddress().getHostAddress().replace('.',
          ',') + ',' + (dataPort >> 8) + ','
      + (dataPort & 255)
      + "\r\n");
  if (getReply() != FTP_OK) {
    throw new IOException("Unable to configure data port");
  }
}
origin: robovm/robovm

/**
 * Returns a connection, which is established via the <code>proxy</code>,
 * to the FTP server specified by this <code>URL</code>. If
 * <code>proxy</code> is DIRECT type, the connection is made in normal
 * way.
 *
 * @param url
 *            the URL which the connection is pointing to
 * @param proxy
 *            the proxy which is used to make the connection
 * @return a connection to the resource pointed by this url.
 *
 * @throws IOException
 *             if this handler fails to establish a connection.
 * @throws IllegalArgumentException
 *             if any argument is null or the type of proxy is wrong.
 * @throws UnsupportedOperationException
 *             if the protocol handler doesn't support this method.
 */
@Override
protected URLConnection openConnection(URL url, Proxy proxy) throws IOException {
  if (url == null || proxy == null) {
    throw new IllegalArgumentException("url == null || proxy == null");
  }
  return new FtpURLConnection(url, proxy);
}
origin: robovm/robovm

/**
 * Creates a output stream for writing to this URL Connection.
 *
 * @return The output stream to write to
 * @throws IOException
 *             when the OutputStream could not be created
 *
 * @see #getContent()
 * @see #getInputStream()
 * @see java.io.IOException
 *
 */
@Override
public OutputStream getOutputStream() throws IOException {
  if (!connected) {
    connect();
  }
  return dataSocket.getOutputStream();
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the content type of the resource. Just takes a guess based on the
 * name.
 */
@Override
public String getContentType() {
  String result = guessContentTypeFromName(url.getFile());
  if (result == null) {
    return "content/unknown";
  }
  return result;
}
origin: com.mobidevelop.robovm/robovm-rt

  connectInternal();
} else {
  ProxySelector selector = ProxySelector.getDefault();
    currentProxy = iter.next();
    try {
      connectInternal();
      connectOK = true;
    } catch (IOException ioe) {
origin: MobiVM/robovm

private void connectInternal() throws IOException {
  int port = url.getPort();
  int connectTimeout = getConnectTimeout();
  if (port <= 0) {
    port = FTP_PORT;
  ctrlOutput = controlSocket.getOutputStream();
  ctrlInput = controlSocket.getInputStream();
  login();
  setType();
  if (!getDoInput()) {
    cd();
    port();
    if (connectTimeout == 0) {
    acceptSocket.setSoTimeout(getConnectTimeout());
    if (getDoInput()) {
      getFile();
    } else {
      sendFile();
    dataSocket.setSoTimeout(getReadTimeout());
    acceptSocket.close();
  } catch (InterruptedIOException e) {
    throw new IOException("Could not establish data connection");
  if (getDoInput()) {
    inputStream = new FtpURLInputStream(
        new BufferedInputStream(dataSocket.getInputStream()), controlSocket);
origin: robovm/robovm

private void login() throws IOException {
  int reply;
  reply = getReply();
  if (reply == FTP_USERREADY) {
  } else {
    throw new IOException("Unable to connect to server: " + url.getHost());
  }
  write("USER " + username + "\r\n");
  reply = getReply();
  if (reply == FTP_PASWD || reply == FTP_LOGGEDIN) {
  } else {
    throw new IOException("Unable to log in to server (USER): " + url.getHost());
  }
  if (reply == FTP_PASWD) {
    write("PASS " + password + "\r\n");
    reply = getReply();
    if (!(reply == FTP_OK || reply == FTP_USERREADY || reply == FTP_LOGGEDIN)) {
      throw new IOException("Unable to log in to server (PASS): " + url.getHost());
    }
  }
}
origin: MobiVM/robovm

/**
 * Open a URLConnection on the given URL.
 */
@Override
protected URLConnection openConnection(URL u) throws IOException {
  return new FtpURLConnection(u);
}
origin: MobiVM/robovm

/**
 * Creates a input stream for writing to this URL Connection.
 *
 * @return The input stream to write to
 * @throws IOException
 *             Cannot read from URL or error creating InputStream
 *
 * @see #getContent()
 * @see #getOutputStream()
 * @see java.io.InputStream
 * @see java.io.IOException
 *
 */
@Override
public InputStream getInputStream() throws IOException {
  if (!connected) {
    connect();
  }
  return inputStream;
}
origin: com.bugvm/bugvm-rt

/**
 * Returns the content type of the resource. Just takes a guess based on the
 * name.
 */
@Override
public String getContentType() {
  String result = guessContentTypeFromName(url.getFile());
  if (result == null) {
    return "content/unknown";
  }
  return result;
}
libcore.net.urlFtpURLConnection

Most used methods

  • <init>
    FtpURLConnection constructor.
  • cd
    Change the server directory to that specified in the URL
  • connect
    Establishes the connection to the resource specified by thisURL
  • connectInternal
  • getConnectTimeout
  • getDoInput
  • getFile
  • getReadTimeout
  • getReply
  • guessContentTypeFromName
  • login
  • port
  • login,
  • port,
  • readLine,
  • readMultiLine,
  • sendFile,
  • setType,
  • write

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • putExtra (Intent)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)