/** Read bytes from the stream into the given buffer. */ public int read(ByteBuffer buf) throws IOException { return raf.read(buf); }
/** * Parse a string from the IM3 file at the current file pointer loc * * @param is stream to read from * @return parsed string or null for string of zero length * @throws IOException */ static protected String parseString(IRandomAccess is) throws IOException { final int nameLength = is.readInt(); if (nameLength == 0) return EMPTY_STRING; final byte [] buf = new byte [nameLength]; is.read(buf); return new String(buf, loci.common.Constants.ENCODING); }
/** * Parse a string from the IM3 file at the current file pointer loc * * @param is stream to read from * @return parsed string or null for string of zero length * @throws IOException */ static protected String parseString(IRandomAccess is) throws IOException { final int nameLength = is.readInt(); if (nameLength == 0) return EMPTY_STRING; final byte [] buf = new byte [nameLength]; is.read(buf); return new String(buf, loci.common.Constants.ENCODING); }
/** * Read n bytes from the stream into the given buffer at the specified offset. */ public int read(ByteBuffer buf, int offset, int n) throws IOException { return raf.read(buf, offset, n); }
int channels = is.readInt(); final byte [] result = new byte [width * height * channels * 2]; is.read(result); return result;
/** * Read n bytes from the stream into the given array at the specified offset. */ @Override public int read(byte[] array, int offset, int n) throws IOException { return raf.read(array, offset, n); }
int channels = is.readInt(); final byte [] result = new byte [width * height * channels * 2]; is.read(result); return result;
/** * Read bytes from the stream into the given buffer. * * @param buf the {@link ByteBuffer} to fill. <code>buf.capacity()</code> * determines the number of bytes to read * @return the number of bytes read * @throws IOException if an error occurred during reading */ public int read(ByteBuffer buf) throws IOException { return raf.read(buf); }
/** * Read n bytes from the stream into the given buffer at the specified offset. * * @param buf the {@link ByteBuffer} to fill * @param offset the offset to the first byte in the buffer * @param n the number of bytes to read * @return the number of bytes actually read * @throws IOException if an error occurred during reading */ public int read(ByteBuffer buf, int offset, int n) throws IOException { return raf.read(buf, offset, n); }
/** * Read n bytes from the stream into the given array at the specified offset. */ @Override public int read(byte[] array, int offset, int n) throws IOException { return raf.read(array, offset, n); }
/** Returns true if the given filename is a Zip file. */ public static boolean isZipFile(String file) throws IOException { if (!file.toLowerCase().endsWith(".zip")) return false; IRandomAccess handle = getHandle(file); byte[] b = new byte[2]; if (handle.length() >= 2) { handle.read(b); } handle.close(); return new String(b, Constants.ENCODING).equals("PK"); }
/** Read bytes from the stream into the given array. */ @Override public int read(byte[] array) throws IOException { int rtn = raf.read(array); if (rtn == 0 && raf.getFilePointer() >= raf.length() - 1) rtn = -1; return rtn; }
/** Read bytes from the stream into the given array. */ @Override public int read(byte[] array) throws IOException { int rtn = raf.read(array); if (rtn == 0 && raf.getFilePointer() >= raf.length() - 1) rtn = -1; return rtn; }
/** * Read n bytes from the stream into the given array at the specified offset. */ @Override public int read(byte[] array, int offset, int n) throws IOException { int rtn = raf.read(array, offset, n); if (rtn == 0 && raf.getFilePointer() >= raf.length() - 1) rtn = -1; return rtn; }
/** * Read n bytes from the stream into the given array at the specified offset. */ @Override public int read(byte[] array, int offset, int n) throws IOException { int rtn = raf.read(array, offset, n); if (rtn == 0 && raf.getFilePointer() >= raf.length() - 1) rtn = -1; return rtn; }
/** * @param file a name that can be passed to * {@link Location#getHandle(String, boolean, boolean)} * @return true if the given filename is a Zip file. * @throws IOException if the file cannot be read */ public static boolean isZipFile(String file) throws IOException { if (!file.toLowerCase().endsWith(".zip")) return false; IRandomAccess handle = getHandle(file); byte[] b = new byte[2]; if (handle.length() >= 2) { handle.read(b); } handle.close(); return new String(b, Constants.ENCODING).equals("PK"); }