List of usage examples for org.apache.commons.vfs2.util RandomAccessMode requestWrite
public boolean requestWrite()
From source file:com.adito.networkplaces.vfs2.provider.smb.SmbFileRandomAccessContent.java
SmbFileRandomAccessContent(final SmbFile smbFile, final RandomAccessMode mode) throws FileSystemException { super(mode);/*from w ww. j a v a 2 s .c o m*/ final StringBuilder modes = new StringBuilder(2); if (mode.requestRead()) { modes.append('r'); } if (mode.requestWrite()) { modes.append('w'); } try { raf = new SmbRandomAccessFile(smbFile, modes.toString()); rafis = new InputStream() { @Override public int read() throws IOException { return raf.readByte(); } @Override public long skip(long n) throws IOException { raf.seek(raf.getFilePointer() + n); return n; } @Override public void close() throws IOException { raf.close(); } @Override public int read(byte b[]) throws IOException { return raf.read(b); } @Override public int read(byte b[], int off, int len) throws IOException { return raf.read(b, off, len); } @Override public int available() throws IOException { long available = raf.length() - raf.getFilePointer(); if (available > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) available; } }; } catch (MalformedURLException e) { throw new FileSystemException("vfs.provider/random-access-open-failed.error", smbFile, e); } catch (SmbException e) { throw new FileSystemException("vfs.provider/random-access-open-failed.error", smbFile, e); } catch (UnknownHostException e) { throw new FileSystemException("vfs.provider/random-access-open-failed.error", smbFile, e); } }