public long getSize() { if (size != null) { return size; } return size = fileObj.getSize(); }
@Override public long getSize() { return delegate.getSize(); }
public long getSize() { return leader.getSize(); }
public int getContentLength() { try { connect(); return (int) fo.getSize(); } catch (IOException ex) { return 0; } }
private void initReader() throws UnsupportedEncodingException, IOException { InputStream is; if (lines.fo.getSize() < 64 * 1024) { if (buffer == null) { buffer = lines.fo.asBytes(); } is = new ByteArrayInputStream(buffer); } else { is = lines.fo.getInputStream(); } this.reader = new BufferedReader(new InputStreamReader(is, encoding)); this.index = 0; while (this.index < index) { next(); } }
/** Reads the full content of the file object and returns it as array of * bytes. * @return array of bytes * @exception IOException in case the content cannot be fully read * @since 7.21 */ public byte[] asBytes() throws IOException { long len = getSize(); if (len > Integer.MAX_VALUE) { throw new IOException("Too big file " + getPath()); // NOI18N } InputStream is = getInputStream(); try { byte[] arr = new byte[(int)len]; int pos = 0; while (pos < arr.length) { int read = is.read(arr, pos, arr.length - pos); if (read == -1) { break; } pos += read; } if (pos != arr.length) { throw new IOException("Just " + pos + " bytes read from " + getPath()); // NOI18N } return arr; } finally { is.close(); } }
/** * Go ahead and retrieve a print or null */ protected Smell sniff(FileObject fo) { if (fo == null) return null; if (fo.equals(lastFileObject)) return print; if (fo.isValid() == false) return null; if (fo.getSize() == 0) return null; print = new Smell(); errors = 0; parse(fo); if (this.state == ERROR) { return null; } lastFileObject = fo; return print; }
public static MIMEResolver forDescriptor(FileObject fo) throws IOException { if (fo.getSize() == 0 && !isUserDefined(fo)) { return create(fo); } return forDescriptor(fo, true); } static MIMEResolver forDescriptor(FileObject fo, boolean warn) {
if (!fo.hasExt("xml") || fo.getSize() == 0) { // NOI18N try { impl = (Impl) MIMEResolverImpl.create(fo);
public int getFileLength() { return (int)fo.getSize(); }
public long getSize () { return leader.getSize (); }
private static boolean fileIsTooBig(FileObject fileObject) { return fileObject != null && fileObject.getSize() > BIG_FILE_SIZE; }
@Override protected CharSequence getCharContentImpl(boolean ignoreEncodingErrors) throws IOException { return FileObjects.getCharContent(openInputStream(), encoding, filter, f.getSize(), ignoreEncodingErrors); } }
public @Override int getContentLength() { try { connect(); return (int) fo.getSize(); } catch (IOException ex) { return 0; } }
private List<FileObject> getFilesToDelete(List<FileObjectWrapper> files) { long sizeSummary = 0; List<FileObject> filesToDelete = new ArrayList<>(); for (FileObjectWrapper file : files) { FileObject fileObject = file.getFileObject(); sizeSummary += fileObject.getSize(); if (sizeSummary > maximumCacheSize) { filesToDelete.add(fileObject); } } return filesToDelete; }
public int getContentLength() { try { connect(); return (int)fo.getSize(); } catch (IOException ex) { return 0; } }
public int getContentLength() { try { connect(); return (int)fo.getSize(); } catch (IOException ex) { return 0; } }
public void deserializeNodeLocation(FileObject navDataFile) { if (navDataFile != null && navDataFile.isValid() && navDataFile.getSize() > 0) { SceneSerializer.deserialize(sceneData, navDataFile); } }
private static boolean isDuplicateEnabled(Node[] nodes) { // It has not much sense to duplicate non-editable templates. // Thus using the same condition: if (nodes != null && nodes.length == 1 && nodes [0].isLeaf ()) { Node n = nodes[0]; DataObject dobj = n.getLookup().lookup(DataObject.class); assert dobj != null : "DataObject for node " + n; FileObject fo = dobj.getPrimaryFile (); return fo.canRevert() || fo.getSize () > 0; } else { return false; } }
/** Find (maybe cached) CRC for a file, using a preexisting input stream (not closed by this method). */ private static String getCrc32(InputStream is, FileObject fo) throws IOException { URL u = fo.getURL(); fo.refresh(); // in case was written on disk and we did not notice yet... long footprint = fo.lastModified().getTime() ^ fo.getSize(); String crc = findCachedCrc32(u, footprint); if (crc == null) { crc = computeCrc32(is); cacheCrc32(crc, u, footprint); } return crc; }