/** * Gets the singleton instance of the utility package. * * @return the singleton instance. */ public static IOUtils getInstance() { if (instance == null) { instance = new IOUtils(); } return instance; }
/** * Copies the InputStream into the OutputStream, until the end of the stream * has been reached. This method uses a buffer of 4096 kbyte. * * @param in the inputstream from which to read. * @param out the outputstream where the data is written to. * @throws IOException if a IOError occurs. */ public void copyStreams(final InputStream in, final OutputStream out) throws IOException { copyStreams(in, out, 4096); }
/** * Copies the contents of the Reader into the Writer, until the end of the * stream has been reached. This method uses a buffer of 4096 kbyte. * * @param in the reader from which to read. * @param out the writer where the data is written to. * @throws IOException if a IOError occurs. */ public void copyWriter(final Reader in, final Writer out) throws IOException { copyWriter(in, out, 4096); }
throw new NullPointerException("baseURL must not be null."); if (isFileStyleProtocol(url) && isSameService(url, baseURL)) { final List urlName = parseName(getPath(url)); final List baseName = parseName(getPath(baseURL)); final String query = getQuery(url); if (!isPath(baseURL)) { baseName.remove(baseName.size() - 1); int commonIndex = startsWithUntil(urlName, baseName); if (commonIndex == 0) { return url.toExternalForm(); return formatName(retval, query);
/** * Extracts the file name from the URL. * * @param url the url. * @return the extracted filename. */ public String getFileName(final URL url) { final String file = getPath(url); final int last = file.lastIndexOf("/"); if (last < 0) { return file; } return file.substring(last + 1); }
throw new NullPointerException("baseURL must not be null."); if (isFileStyleProtocol(url) && isSameService(url, baseURL)) { final List urlName = parseName(getPath(url)); final List baseName = parseName(getPath(baseURL)); final String query = getQuery(url); if (!isPath(baseURL)) { baseName.remove(baseName.size() - 1); int commonIndex = startsWithUntil(urlName, baseName); if (commonIndex == 0) { return url.toExternalForm(); return formatName(retval, query);
/** * Extracts the file name from the URL. * * @param url the url. * @return the extracted filename. */ public String getFileName(final URL url) { final String file = getPath(url); final int last = file.lastIndexOf("/"); if (last < 0) { return file; } return file.substring(last + 1); }
throw new NullPointerException("baseURL must not be null."); if (isFileStyleProtocol(url) && isSameService(url, baseURL)) { final List urlName = parseName(getPath(url)); final List baseName = parseName(getPath(baseURL)); final String query = getQuery(url); if (!isPath(baseURL)) { baseName.remove(baseName.size() - 1); int commonIndex = startsWithUntil(urlName, baseName); if (commonIndex == 0) { return url.toExternalForm(); return formatName(retval, query);
/** * Returns <code>true</code> if the URL represents a path, and * <code>false</code> otherwise. * * @param baseURL the URL. * * @return A boolean. */ private boolean isPath(final URL baseURL) { if (getPath(baseURL).endsWith("/")) { return true; } else if (baseURL.getProtocol().equals("file")) { final File f = new File(getPath(baseURL)); try { if (f.isDirectory()) { return true; } } catch (SecurityException se) { // ignored ... } } return false; }
/** * Copies the contents of the Reader into the Writer, until the end of the * stream has been reached. This method uses a buffer of 4096 kbyte. * * @param in the reader from which to read. * @param out the writer where the data is written to. * @throws IOException if a IOError occurs. */ public void copyWriter(final Reader in, final Writer out) throws IOException { copyWriter(in, out, 4096); }
/** * Gets the singleton instance of the utility package. * * @return the singleton instance. */ public static IOUtils getInstance() { if (instance == null) { instance = new IOUtils(); } return instance; }
/** * Copies the InputStream into the OutputStream, until the end of the stream * has been reached. This method uses a buffer of 4096 kbyte. * * @param in the inputstream from which to read. * @param out the outputstream where the data is written to. * @throws IOException if a IOError occurs. */ public void copyStreams(final InputStream in, final OutputStream out) throws IOException { copyStreams(in, out, 4096); }
/** * Returns <code>true</code> if the URL represents a path, and * <code>false</code> otherwise. * * @param baseURL the URL. * * @return A boolean. */ private boolean isPath(final URL baseURL) { if (getPath(baseURL).endsWith("/")) { return true; } else if (baseURL.getProtocol().equals("file")) { final File f = new File(getPath(baseURL)); try { if (f.isDirectory()) { return true; } } catch (SecurityException se) { // ignored ... } } return false; }
/** * Copies the contents of the Reader into the Writer, until the end of the * stream has been reached. This method uses a buffer of 4096 kbyte. * * @param in the reader from which to read. * @param out the writer where the data is written to. * @throws IOException if a IOError occurs. */ public void copyWriter(final Reader in, final Writer out) throws IOException { copyWriter(in, out, 4096); }
/** * Gets the singleton instance of the utility package. * * @return the singleton instance. */ public static IOUtils getInstance() { if (instance == null) { instance = new IOUtils(); } return instance; }
/** * Copies the InputStream into the OutputStream, until the end of the stream * has been reached. This method uses a buffer of 4096 kbyte. * * @param in the inputstream from which to read. * @param out the outputstream where the data is written to. * @throws IOException if a IOError occurs. */ public void copyStreams(final InputStream in, final OutputStream out) throws IOException { copyStreams(in, out, 4096); }
/** * Returns <code>true</code> if the URL represents a path, and * <code>false</code> otherwise. * * @param baseURL the URL. * * @return A boolean. */ private boolean isPath(final URL baseURL) { if (getPath(baseURL).endsWith("/")) { return true; } else if (baseURL.getProtocol().equals("file")) { final File f = new File(getPath(baseURL)); try { if (f.isDirectory()) { return true; } } catch (SecurityException se) { // ignored ... } } return false; }