Codota Logo
FileURLConnection
Code IndexAdd Codota to your IDE (free)

How to use
FileURLConnection
in
libcore.net.url

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: robovm/robovm

/**
 * The behavior of this method is the same as openConnection(URL).
 * <code>proxy</code> is not used in FileURLConnection.
 *
 * @param url
 *            the URL which the connection is pointing to
 * @param proxy
 *            Proxy
 * @return a connection to the resource pointed by this url.
 *
 * @throws IOException
 *             if this handler fails to establish a connection.
 * @throws IllegalArgumentException
 *             if the url argument is null.
 * @throws UnsupportedOperationException
 *             if the protocol handler doesn't support this method.
 */
@Override
public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  String host = url.getHost();
  if (host == null || host.isEmpty() || host.equalsIgnoreCase("localhost")) {
    return new FileURLConnection(url);
  }
  // If a hostname is specified try to get the resource using FTP
  URL ftpURL = new URL("ftp", host, url.getFile());
  return (proxy == null) ? ftpURL.openConnection() : ftpURL.openConnection(proxy);
}
origin: robovm/robovm

try {
  if (!connected) {
    connect();
  return "text/plain";
String result = guessContentTypeFromName(url.getFile());
if (result != null) {
  return result;
  result = guessContentTypeFromStream(is);
} catch (IOException e) {
origin: robovm/robovm

/**
 * This methods will attempt to obtain the input stream of the file pointed
 * by this <code>URL</code>. If the file is a directory, it will return
 * that directory listing as an input stream.
 *
 * @throws IOException
 *             if an IO error occurs while connecting
 */
@Override
public void connect() throws IOException {
  File f = new File(filename);
  if (f.isDirectory()) {
    isDir = true;
    is = getDirectoryListing(f);
    // use -1 for the contentLength
  } else {
    is = new BufferedInputStream(new FileInputStream(f));
    long lengthAsLong = f.length();
    length = lengthAsLong <= Integer.MAX_VALUE ? (int) lengthAsLong : Integer.MAX_VALUE;
  }
  connected = true;
}
origin: robovm/robovm

/**
 * Returns the length of the file in bytes.
 *
 * @return the length of the file
 *
 * @see #getContentType()
 */
@Override
public int getContentLength() {
  try {
    if (!connected) {
      connect();
    }
  } catch (IOException e) {
    // default is -1
  }
  return length;
}
origin: robovm/robovm

/**
 * Returns the input stream of the object referred to by this
 * <code>URLConnection</code>
 *
 * File Sample : "/ZIP211/+/harmony/tools/javac/resources/javac.properties"
 * Invalid File Sample:
 * "/ZIP/+/harmony/tools/javac/resources/javac.properties"
 * "ZIP211/+/harmony/tools/javac/resources/javac.properties"
 *
 * @return input stream of the object
 *
 * @throws IOException
 *             if an IO error occurs
 */
@Override
public InputStream getInputStream() throws IOException {
  if (!connected) {
    connect();
  }
  return is;
}
origin: MobiVM/robovm

try {
  if (!connected) {
    connect();
  return "text/plain";
String result = guessContentTypeFromName(url.getFile());
if (result != null) {
  return result;
  result = guessContentTypeFromStream(is);
} catch (IOException e) {
origin: MobiVM/robovm

/**
 * Returns the length of the file in bytes.
 *
 * @return the length of the file
 *
 * @see #getContentType()
 */
@Override
public int getContentLength() {
  try {
    if (!connected) {
      connect();
    }
  } catch (IOException e) {
    // default is -1
  }
  return length;
}
origin: MobiVM/robovm

/**
 * This methods will attempt to obtain the input stream of the file pointed
 * by this <code>URL</code>. If the file is a directory, it will return
 * that directory listing as an input stream.
 *
 * @throws IOException
 *             if an IO error occurs while connecting
 */
@Override
public void connect() throws IOException {
  File f = new File(filename);
  if (f.isDirectory()) {
    isDir = true;
    is = getDirectoryListing(f);
    // use -1 for the contentLength
  } else {
    is = new BufferedInputStream(new FileInputStream(f));
    long lengthAsLong = f.length();
    length = lengthAsLong <= Integer.MAX_VALUE ? (int) lengthAsLong : Integer.MAX_VALUE;
  }
  connected = true;
}
origin: com.gluonhq/robovm-rt

/**
 * The behavior of this method is the same as openConnection(URL).
 * <code>proxy</code> is not used in FileURLConnection.
 *
 * @param url
 *            the URL which the connection is pointing to
 * @param proxy
 *            Proxy
 * @return a connection to the resource pointed by this url.
 *
 * @throws IOException
 *             if this handler fails to establish a connection.
 * @throws IllegalArgumentException
 *             if the url argument is null.
 * @throws UnsupportedOperationException
 *             if the protocol handler doesn't support this method.
 */
@Override
public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  String host = url.getHost();
  if (host == null || host.isEmpty() || host.equalsIgnoreCase("localhost")) {
    return new FileURLConnection(url);
  }
  // If a hostname is specified try to get the resource using FTP
  URL ftpURL = new URL("ftp", host, url.getFile());
  return (proxy == null) ? ftpURL.openConnection() : ftpURL.openConnection(proxy);
}
origin: com.bugvm/bugvm-rt

try {
  if (!connected) {
    connect();
  return "text/plain";
String result = guessContentTypeFromName(url.getFile());
if (result != null) {
  return result;
  result = guessContentTypeFromStream(is);
} catch (IOException e) {
origin: com.gluonhq/robovm-rt

/**
 * Returns the length of the file in bytes.
 *
 * @return the length of the file
 *
 * @see #getContentType()
 */
@Override
public int getContentLength() {
  try {
    if (!connected) {
      connect();
    }
  } catch (IOException e) {
    // default is -1
  }
  return length;
}
origin: ibinti/bugvm

/**
 * This methods will attempt to obtain the input stream of the file pointed
 * by this <code>URL</code>. If the file is a directory, it will return
 * that directory listing as an input stream.
 *
 * @throws IOException
 *             if an IO error occurs while connecting
 */
@Override
public void connect() throws IOException {
  File f = new File(filename);
  if (f.isDirectory()) {
    isDir = true;
    is = getDirectoryListing(f);
    // use -1 for the contentLength
  } else {
    is = new BufferedInputStream(new FileInputStream(f));
    long lengthAsLong = f.length();
    length = lengthAsLong <= Integer.MAX_VALUE ? (int) lengthAsLong : Integer.MAX_VALUE;
  }
  connected = true;
}
origin: MobiVM/robovm

/**
 * The behavior of this method is the same as openConnection(URL).
 * <code>proxy</code> is not used in FileURLConnection.
 *
 * @param url
 *            the URL which the connection is pointing to
 * @param proxy
 *            Proxy
 * @return a connection to the resource pointed by this url.
 *
 * @throws IOException
 *             if this handler fails to establish a connection.
 * @throws IllegalArgumentException
 *             if the url argument is null.
 * @throws UnsupportedOperationException
 *             if the protocol handler doesn't support this method.
 */
@Override
public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  String host = url.getHost();
  if (host == null || host.isEmpty() || host.equalsIgnoreCase("localhost")) {
    return new FileURLConnection(url);
  }
  // If a hostname is specified try to get the resource using FTP
  URL ftpURL = new URL("ftp", host, url.getFile());
  return (proxy == null) ? ftpURL.openConnection() : ftpURL.openConnection(proxy);
}
origin: ibinti/bugvm

try {
  if (!connected) {
    connect();
  return "text/plain";
String result = guessContentTypeFromName(url.getFile());
if (result != null) {
  return result;
  result = guessContentTypeFromStream(is);
} catch (IOException e) {
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the length of the file in bytes.
 *
 * @return the length of the file
 *
 * @see #getContentType()
 */
@Override
public int getContentLength() {
  try {
    if (!connected) {
      connect();
    }
  } catch (IOException e) {
    // default is -1
  }
  return length;
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * This methods will attempt to obtain the input stream of the file pointed
 * by this <code>URL</code>. If the file is a directory, it will return
 * that directory listing as an input stream.
 *
 * @throws IOException
 *             if an IO error occurs while connecting
 */
@Override
public void connect() throws IOException {
  File f = new File(filename);
  if (f.isDirectory()) {
    isDir = true;
    is = getDirectoryListing(f);
    // use -1 for the contentLength
  } else {
    is = new BufferedInputStream(new FileInputStream(f));
    long lengthAsLong = f.length();
    length = lengthAsLong <= Integer.MAX_VALUE ? (int) lengthAsLong : Integer.MAX_VALUE;
  }
  connected = true;
}
origin: FlexoVM/flexovm

/**
 * The behavior of this method is the same as openConnection(URL).
 * <code>proxy</code> is not used in FileURLConnection.
 *
 * @param url
 *            the URL which the connection is pointing to
 * @param proxy
 *            Proxy
 * @return a connection to the resource pointed by this url.
 *
 * @throws IOException
 *             if this handler fails to establish a connection.
 * @throws IllegalArgumentException
 *             if the url argument is null.
 * @throws UnsupportedOperationException
 *             if the protocol handler doesn't support this method.
 */
@Override
public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  String host = url.getHost();
  if (host == null || host.isEmpty() || host.equalsIgnoreCase("localhost")) {
    return new FileURLConnection(url);
  }
  // If a hostname is specified try to get the resource using FTP
  URL ftpURL = new URL("ftp", host, url.getFile());
  return (proxy == null) ? ftpURL.openConnection() : ftpURL.openConnection(proxy);
}
origin: com.mobidevelop.robovm/robovm-rt

try {
  if (!connected) {
    connect();
  return "text/plain";
String result = guessContentTypeFromName(url.getFile());
if (result != null) {
  return result;
  result = guessContentTypeFromStream(is);
} catch (IOException e) {
origin: com.bugvm/bugvm-rt

/**
 * Returns the length of the file in bytes.
 *
 * @return the length of the file
 *
 * @see #getContentType()
 */
@Override
public int getContentLength() {
  try {
    if (!connected) {
      connect();
    }
  } catch (IOException e) {
    // default is -1
  }
  return length;
}
origin: com.bugvm/bugvm-rt

/**
 * This methods will attempt to obtain the input stream of the file pointed
 * by this <code>URL</code>. If the file is a directory, it will return
 * that directory listing as an input stream.
 *
 * @throws IOException
 *             if an IO error occurs while connecting
 */
@Override
public void connect() throws IOException {
  File f = new File(filename);
  if (f.isDirectory()) {
    isDir = true;
    is = getDirectoryListing(f);
    // use -1 for the contentLength
  } else {
    is = new BufferedInputStream(new FileInputStream(f));
    long lengthAsLong = f.length();
    length = lengthAsLong <= Integer.MAX_VALUE ? (int) lengthAsLong : Integer.MAX_VALUE;
  }
  connected = true;
}
libcore.net.urlFileURLConnection

Javadoc

This subclass extends URLConnection.

This class is responsible for connecting, getting content and input stream of the file.

Most used methods

  • <init>
    Creates an instance of FileURLConnection for establishing a connection to the file pointed by this U
  • connect
    This methods will attempt to obtain the input stream of the file pointed by this URL. If the file i
  • getDirectoryListing
    Returns the directory listing of the file component as an input stream.
  • guessContentTypeFromName
  • guessContentTypeFromStream

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • JFileChooser (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now