/** * Returns the size of the file. * * @return The size of the file, in bytes. */ public long getSize() { if (cachedContent != null) { return cachedContent.length; } else if (dfos.isInMemory()) { return dfos.getData().length; } else { return dfos.getFile().length(); } }
/** * Returns an {@link java.io.InputStream InputStream} that can be used to retrieve the contents * of the file. * * @return An {@link java.io.InputStream InputStream} that can be used to retrieve the contents * of the file. * * @throws IOException * if an error occurs. */ public InputStream getInputStream() throws IOException { if (!isInMemory()) { return new FileInputStream(dfos.getFile()); } if (cachedContent == null) { cachedContent = dfos.getData(); } return new ByteArrayInputStream(cachedContent); }
/** * Returns an {@link java.io.InputStream InputStream} that can be used to retrieve the contents * of the file. * * @return An {@link java.io.InputStream InputStream} that can be used to retrieve the contents * of the file. * * @exception IOException * if an error occurs. */ public InputStream getInputStream() throws IOException { if (!dfos.isInMemory()) { return new FileInputStream(dfos.getFile()); } if (cachedContent == null) { cachedContent = dfos.getData(); } return new ByteArrayInputStream(cachedContent); }
/** * Returns the size of the file. * * @return The size of the file, in bytes. */ public long getSize() { if (size >= 0) { return size; } else if (cachedContent != null) { return cachedContent.length; } else if (dfos.isInMemory()) { return dfos.getData().length; } else { return dfos.getFile().length(); } }
cachedContent = dfos.getData();
cachedContent = dfos.getData();