} else { try { url = createAbsoluteUrl(name); } catch (IOException iex) { url = null;
public long getSize (String name) { if (content == null) return 0; if (content instanceof byte[]) return ((byte[])content).length; if (content instanceof String) { try { URL absURL = createAbsoluteUrl (name); URLConnection urlConnection = absURL.openConnection(); try { return urlConnection.getContentLength(); } finally { urlConnection.getInputStream().close(); } } catch (IOException iex) { } } return 0; }
public long getSize (String name) { if (content == null) return 0; if (content instanceof byte[]) return ((byte[])content).length; if (content instanceof String) { try { URL absURL = createAbsoluteUrl (name); URLConnection urlConnection = absURL.openConnection(); try { return urlConnection.getContentLength(); } finally { urlConnection.getInputStream().close(); } } catch (IOException iex) { } } return 0; }
/** * Get input stream. * * @return an input stream to read the contents of this file * @param context * @param name the file to test * @exception FileNotFoundException if the file does not exists or is invalid */ public InputStream getInputStream(String name) throws java.io.FileNotFoundException { InputStream is = null; if (content == null) return new ByteArrayInputStream (new byte[] {}); if (content instanceof String) { URL absURL = createAbsoluteUrl (name); try { is = absURL.openStream(); } catch (IOException iox) { FileNotFoundException x = new FileNotFoundException (name); ExternalUtil.copyAnnotation (x,iox); throw x; } } if (content instanceof byte[]){ is = new ByteArrayInputStream((byte[])content); } if (is == null) throw new FileNotFoundException (name); return is; }
/** * Get input stream. * * @return an input stream to read the contents of this file * @param context * @param name the file to test * @exception FileNotFoundException if the file does not exists or is invalid */ public InputStream getInputStream(String name) throws java.io.FileNotFoundException { InputStream is = null; if (content == null) return new ByteArrayInputStream (new byte[] {}); if (content instanceof String) { URL absURL = createAbsoluteUrl (name); try { is = absURL.openStream(); } catch (IOException iox) { FileNotFoundException x = new FileNotFoundException (name); ExternalUtil.copyAnnotation (x,iox); throw x; } } if (content instanceof byte[]){ is = new ByteArrayInputStream((byte[])content); } if (is == null) throw new FileNotFoundException (name); return is; }
public Date lastModified(String name) { if (content == null || !(content instanceof String)) return timeFromDateHeaderField (getLayers ()); URL url; try { url = createAbsoluteUrl (name); } catch (IOException iex) { return timeFromDateHeaderField (getLayers ()); } File localFile = getLocalFile (url); if (localFile != null) return new Date (localFile.lastModified()); return timeFromDateHeaderField (url); }
public Date lastModified(String name) { if (content == null || !(content instanceof String)) return timeFromDateHeaderField (getLayers ()); URL url; try { url = createAbsoluteUrl (name); } catch (IOException iex) { return timeFromDateHeaderField (getLayers ()); } File localFile = getLocalFile (url); if (localFile != null) return new Date (localFile.lastModified()); return timeFromDateHeaderField (url); }