Tabnine Logo
JarURLConnectionImpl
Code IndexAdd Tabnine to your IDE (free)

How to use
JarURLConnectionImpl
in
libcore.net.url

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

origin: robovm/robovm

/**
 * Returns a connection to the jar file pointed by this <code>URL</code>
 * in the file system
 *
 * @return java.net.URLConnection A connection to the resource pointed by
 *         this url.
 * @param u
 *            java.net.URL The URL to which the connection is pointing to
 *
 * @throws IOException
 *             thrown if an IO error occurs when this method tries to
 *             establish connection.
 */
@Override
protected URLConnection openConnection(URL u) throws IOException {
  return new JarURLConnectionImpl(u);
}
origin: robovm/robovm

String entryName = getEntryName();
  cType = guessContentTypeFromName(entryName);
} else {
  try {
    connect();
    cType = jarFileURLConnection.getContentType();
  } catch (IOException ioe) {
origin: robovm/robovm

/**
 * @see java.net.URLConnection#connect()
 */
@Override
public void connect() throws IOException {
  if (!connected) {
    findJarFile(); // ensure the file can be found
    findJarEntry(); // ensure the entry, if any, can be found
    connected = true;
  }
}
origin: robovm/robovm

/**
 * Returns the content length of the resource. Test cases reveal that if the
 * URL is referring to a Jar file, this method answers a content-length
 * returned by URLConnection. For jar entry it should return it's size.
 * Otherwise, it will return -1.
 *
 * @return the content length
 */
@Override
public int getContentLength() {
  try {
    connect();
    if (jarEntry == null) {
      return jarFileURLConnection.getContentLength();
    }
    return (int) getJarEntry().getSize();
  } catch (IOException e) {
    // Ignored
  }
  return -1;
}
origin: robovm/robovm

/**
 * Returns the Jar file referred by this {@code URLConnection}.
 *
 * @throws IOException
 *             thrown if an IO error occurs while connecting to the
 *             resource.
 */
@Override
public JarFile getJarFile() throws IOException {
  connect();
  return jarFile;
}
origin: robovm/robovm

/**
 * Returns the Jar file referred by this {@code URLConnection}
 *
 * @throws IOException
 *             if an IO error occurs while connecting to the resource.
 */
private void findJarFile() throws IOException {
  if (getUseCaches()) {
    synchronized (jarCache) {
      jarFile = jarCache.get(jarFileURL);
    }
    if (jarFile == null) {
      JarFile jar = openJarFile();
      synchronized (jarCache) {
        jarFile = jarCache.get(jarFileURL);
        if (jarFile == null) {
          jarCache.put(jarFileURL, jar);
          jarFile = jar;
        } else {
          jar.close();
        }
      }
    }
  } else {
    jarFile = openJarFile();
  }
  if (jarFile == null) {
    throw new IOException();
  }
}
origin: robovm/robovm

  @Override
  public void close() throws IOException {
    super.close();
    if (!getUseCaches()) {
      closed = true;
      jarFile.close();
    }
  }
}
origin: robovm/robovm

/**
 * @param url
 *            the URL of the JAR
 * @throws MalformedURLException
 *             if the URL is malformed
 * @throws IOException
 *             if there is a problem opening the connection.
 */
public JarURLConnectionImpl(URL url) throws MalformedURLException, IOException {
  super(url);
  jarFileURL = getJarFileURL();
  jarFileURLConnection = jarFileURL.openConnection();
}
origin: robovm/robovm

/**
 * Look up the JarEntry of the entry referenced by this {@code
 * URLConnection}.
 */
private void findJarEntry() throws IOException {
  if (getEntryName() == null) {
    return;
  }
  jarEntry = jarFile.getJarEntry(getEntryName());
  if (jarEntry == null) {
    throw new FileNotFoundException(getEntryName());
  }
}
origin: robovm/robovm

/**
 * Returns the JarEntry of the entry referenced by this {@code
 * URLConnection}.
 *
 * @return the JarEntry referenced
 *
 * @throws IOException
 *             if an IO error occurs while getting the entry
 */
@Override
public JarEntry getJarEntry() throws IOException {
  connect();
  return jarEntry;
}
origin: MobiVM/robovm

/**
 * Returns the content length of the resource. Test cases reveal that if the
 * URL is referring to a Jar file, this method answers a content-length
 * returned by URLConnection. For jar entry it should return it's size.
 * Otherwise, it will return -1.
 *
 * @return the content length
 */
@Override
public int getContentLength() {
  try {
    connect();
    if (jarEntry == null) {
      return jarFileURLConnection.getContentLength();
    }
    return (int) getJarEntry().getSize();
  } catch (IOException e) {
    // Ignored
  }
  return -1;
}
origin: MobiVM/robovm

/**
 * Returns the Jar file referred by this {@code URLConnection}
 *
 * @throws IOException
 *             if an IO error occurs while connecting to the resource.
 */
private void findJarFile() throws IOException {
  if (getUseCaches()) {
    synchronized (jarCache) {
      jarFile = jarCache.get(jarFileURL);
    }
    if (jarFile == null) {
      JarFile jar = openJarFile();
      synchronized (jarCache) {
        jarFile = jarCache.get(jarFileURL);
        if (jarFile == null) {
          jarCache.put(jarFileURL, jar);
          jarFile = jar;
        } else {
          jar.close();
        }
      }
    }
  } else {
    jarFile = openJarFile();
  }
  if (jarFile == null) {
    throw new IOException();
  }
}
origin: ibinti/bugvm

  @Override
  public void close() throws IOException {
    super.close();
    if (!getUseCaches()) {
      closed = true;
      jarFile.close();
    }
  }
}
origin: MobiVM/robovm

/**
 * @param url
 *            the URL of the JAR
 * @throws MalformedURLException
 *             if the URL is malformed
 * @throws IOException
 *             if there is a problem opening the connection.
 */
public JarURLConnectionImpl(URL url) throws MalformedURLException, IOException {
  super(url);
  jarFileURL = getJarFileURL();
  jarFileURLConnection = jarFileURL.openConnection();
}
origin: MobiVM/robovm

/**
 * Look up the JarEntry of the entry referenced by this {@code
 * URLConnection}.
 */
private void findJarEntry() throws IOException {
  if (getEntryName() == null) {
    return;
  }
  jarEntry = jarFile.getJarEntry(getEntryName());
  if (jarEntry == null) {
    throw new FileNotFoundException(getEntryName());
  }
}
origin: MobiVM/robovm

String entryName = getEntryName();
  cType = guessContentTypeFromName(entryName);
} else {
  try {
    connect();
    cType = jarFileURLConnection.getContentType();
  } catch (IOException ioe) {
origin: ibinti/bugvm

/**
 * @see java.net.URLConnection#connect()
 */
@Override
public void connect() throws IOException {
  if (!connected) {
    findJarFile(); // ensure the file can be found
    findJarEntry(); // ensure the entry, if any, can be found
    connected = true;
  }
}
origin: robovm/robovm

/**
 * Creates an input stream for reading from this URL Connection.
 *
 * @return the input stream
 *
 * @throws IOException
 *             if an IO error occurs while connecting to the resource.
 */
@Override
public InputStream getInputStream() throws IOException {
  if (closed) {
    throw new IllegalStateException("JarURLConnection InputStream has been closed");
  }
  connect();
  if (jarInput != null) {
    return jarInput;
  }
  if (jarEntry == null) {
    throw new IOException("Jar entry not specified");
  }
  return jarInput = new JarURLConnectionInputStream(jarFile
      .getInputStream(jarEntry), jarFile);
}
origin: ibinti/bugvm

/**
 * Returns the content length of the resource. Test cases reveal that if the
 * URL is referring to a Jar file, this method answers a content-length
 * returned by URLConnection. For jar entry it should return it's size.
 * Otherwise, it will return -1.
 *
 * @return the content length
 */
@Override
public int getContentLength() {
  try {
    connect();
    if (jarEntry == null) {
      return jarFileURLConnection.getContentLength();
    }
    return (int) getJarEntry().getSize();
  } catch (IOException e) {
    // Ignored
  }
  return -1;
}
origin: ibinti/bugvm

/**
 * Returns the Jar file referred by this {@code URLConnection}
 *
 * @throws IOException
 *             if an IO error occurs while connecting to the resource.
 */
private void findJarFile() throws IOException {
  if (getUseCaches()) {
    synchronized (jarCache) {
      jarFile = jarCache.get(jarFileURL);
    }
    if (jarFile == null) {
      JarFile jar = openJarFile();
      synchronized (jarCache) {
        jarFile = jarCache.get(jarFileURL);
        if (jarFile == null) {
          jarCache.put(jarFileURL, jar);
          jarFile = jar;
        } else {
          jar.close();
        }
      }
    }
  } else {
    jarFile = openJarFile();
  }
  if (jarFile == null) {
    throw new IOException();
  }
}
libcore.net.urlJarURLConnectionImpl

Javadoc

This subclass extends URLConnection.

This class is responsible for connecting and retrieving resources from a Jar file which can be anywhere that can be referred to by an URL.

Most used methods

  • <init>
  • connect
  • findJarEntry
    Look up the JarEntry of the entry referenced by this URLConnection.
  • findJarFile
    Returns the Jar file referred by this URLConnection
  • getEntryName
  • getJarEntry
    Returns the JarEntry of the entry referenced by this URLConnection.
  • getJarFileURL
  • getUseCaches
  • guessContentTypeFromName
  • openJarFile

Popular in Java

  • Reactive rest calls using spring rest template
  • setContentView (Activity)
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Notification (javax.management)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now