/** * Gets an IRandomAccess object that can read from or write to the given file. * @see IRandomAccess */ public static IRandomAccess getHandle(String id, boolean writable) throws IOException { return getHandle(id, writable, true); }
/** * Gets an IRandomAccess object that can read from the given file. * @see IRandomAccess */ public static IRandomAccess getHandle(String id) throws IOException { return getHandle(id, false); }
/** * Constructs a random access stream around the given file. * @param file Filename to open the stream for. * @throws IOException If there is a problem opening the file. */ public RandomAccessOutputStream(String file) throws IOException { outputFile = Location.getHandle(file, true); }
/** * Constructs a hybrid RandomAccessFile/DataInputStream * around the given file. * * @param file a name that can be passed to {@link Location#getHandle(String)} * @param bufferSize the size of the caching buffer in bytes * @throws IOException if the name is invalid */ public RandomAccessInputStream(String file, int bufferSize) throws IOException { this(Location.getHandle(file, false, true, bufferSize), file); }
/** * Constructs a hybrid RandomAccessFile/DataInputStream * around the given file. * * @param file a name that can be passed to {@link Location#getHandle(String)} * @throws IOException if the name is invalid */ public RandomAccessInputStream(String file) throws IOException { this(Location.getHandle(file), file); }
/** * Gets an IRandomAccess object that can read from or write to the given file. * @see IRandomAccess */ public static IRandomAccess getHandle(String id, boolean writable, boolean allowArchiveHandles) throws IOException { return getHandle(id, writable, allowArchiveHandles, 0); }
/** * Constructs a hybrid RandomAccessFile/DataInputStream * around the given file. */ public RandomAccessInputStream(String file) throws IOException { this(Location.getHandle(file), file); }
/** * Constructs a hybrid RandomAccessFile/DataInputStream * around the given file. */ public RandomAccessInputStream(String file, int bufferSize) throws IOException { this(Location.getHandle(file, false, true, bufferSize), file); }
/** * Constructs a random access stream around the given file. * @param file Filename to open the stream for. * @throws IOException If there is a problem opening the file. */ public RandomAccessOutputStream(String file) throws IOException { outputFile = Location.getHandle(file, true); }
/** * Gets an IRandomAccess object that can read from the given file. * * @param id the name for which to locate an IRandomAccess * @return a previously mapped IRandomAccess, or a new IRandomAccess * according to the name's type (URL, filesystem path, etc.) * @throws IOException if a valid IRandomAccess cannot be created * @see #getHandle(String, boolean, boolean, int) * @see IRandomAccess */ public static IRandomAccess getHandle(String id) throws IOException { return getHandle(id, false); }
private static IRandomAccess getHandle(String file) throws IOException { return Location.getHandle(file, false, false); }
private static IRandomAccess getHandle(String file) throws IOException { return Location.getHandle(file, false, false); }
/** * Gets an IRandomAccess object that can read from or write to the given file. * * @param id the name for which to locate an IRandomAccess * @param writable true if the returned IRandomAccess should have write permission * @return a previously mapped IRandomAccess, or a new IRandomAccess * according to the name's type (URL, filesystem path, etc.) * @throws IOException if a valid IRandomAccess cannot be created * @see #getHandle(String, boolean, boolean, int) * @see IRandomAccess */ public static IRandomAccess getHandle(String id, boolean writable) throws IOException { return getHandle(id, writable, true); }
/** * Gets an IRandomAccess object that can read from or write to the given file. * * @param id the name for which to locate an IRandomAccess * @param writable true if the returned IRandomAccess should have write permission * @param allowArchiveHandles true if checks for compressed/archive file types * (e.g. Zip, GZip, BZip2) should be enabled * @return a previously mapped IRandomAccess, or a new IRandomAccess * according to the name's type (URL, filesystem path, etc.) * @throws IOException if a valid IRandomAccess cannot be created * @see #getHandle(String, boolean, boolean, int) * @see IRandomAccess */ public static IRandomAccess getHandle(String id, boolean writable, boolean allowArchiveHandles) throws IOException { return getHandle(id, writable, allowArchiveHandles, 0); }
/** * Checks that the given id points at a valid data stream. * * @param id * The id string to validate. * @throws IOException * if the id is not valid. */ public static void checkValidId(String id) throws IOException { if (getMappedFile(id) != null) { // NB: The id maps directly to an IRandomAccess handle, so is valid. Do // not destroy an existing mapped IRandomAccess handle by closing it. return; } // NB: Try to actually open a handle to make sure it is valid. Close it // afterward so we don't leave it dangling. The process of doing this will // throw IOException if something goes wrong. Location.getHandle(id).close(); }
/** * Checks that the given id points at a valid data stream. * * @param id * The id string to validate. * @throws IOException * if the id is not valid. */ public static void checkValidId(String id) throws IOException { if (getMappedFile(id) != null) { // NB: The id maps directly to an IRandomAccess handle, so is valid. Do // not destroy an existing mapped IRandomAccess handle by closing it. return; } // NB: Try to actually open a handle to make sure it is valid. Close it // afterward so we don't leave it dangling. The process of doing this will // throw IOException if something goes wrong. Location.getHandle(id).close(); }
@Override public void read(Kryo kryo, Input in) { raf = (IRandomAccess) kryo.readClassAndObject(in); file = kryo.readObjectOrNull(in, String.class); if (file != null) { try { raf = Location.getHandle(file); } catch (IOException e) { LOGGER.warn("Failed to reopen file", e); } } length = kryo.readObject(in, Long.class); markedPos = kryo.readObject(in, Long.class); encoding = kryo.readObject(in, String.class); }
@Override public void read(Kryo kryo, Input in) { raf = (IRandomAccess) kryo.readClassAndObject(in); file = kryo.readObjectOrNull(in, String.class); if (file != null) { try { raf = Location.getHandle(file); } catch (IOException e) { LOGGER.warn("Failed to reopen file", e); } } length = kryo.readObject(in, Long.class); markedPos = kryo.readObject(in, Long.class); encoding = kryo.readObject(in, String.class); }
/** * Write a summary of each field in the IM3 file to the writer * @throws IOException */ public void writeSummary() throws IOException { IRandomAccess is = Location.getHandle(getCurrentFile(), false); try { is.setOrder(ByteOrder.LITTLE_ENDIAN); for (IM3Record rec: records) { rec.writeSummary(is, ""); } } finally { is.close(); } } /**
/** * Write a summary of each field in the IM3 file to the writer * @throws IOException */ public void writeSummary() throws IOException { IRandomAccess is = Location.getHandle(getCurrentFile(), false); try { is.setOrder(ByteOrder.LITTLE_ENDIAN); for (IM3Record rec: records) { rec.writeSummary(is, ""); } } finally { is.close(); } } /**