@Override public void write(byte[] b, int off, int len) throws IOException { try { fos.write(b, off, len); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(int b) throws IOException { try { fos.write(b); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } } }
@Override public int read() throws IOException { try { int value = fis.read(); if (value >= 0) { this.position++; statistics.incrementBytesRead(1); } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public boolean truncate(Path f, final long newLength) throws IOException { FileStatus status = getFileStatus(f); if(status == null) { throw new FileNotFoundException("File " + f + " not found"); } if(status.isDirectory()) { throw new IOException("Cannot truncate a directory (=" + f + ")"); } long oldLength = status.getLen(); if(newLength > oldLength) { throw new IllegalArgumentException( "Cannot truncate to a larger file size. Current size: " + oldLength + ", truncate size: " + newLength + "."); } try (FileOutputStream out = new FileOutputStream(pathToFile(f), true)) { try { out.getChannel().truncate(newLength); } catch(IOException e) { throw new FSError(e); } } return true; }
@Override public int read(long position, byte[] b, int off, int len) throws IOException { // parameter check validatePositionedReadArgs(position, b, off, len); if (len == 0) { return 0; } ByteBuffer bb = ByteBuffer.wrap(b, off, len); try { int value = fis.getChannel().read(bb, position); if (value > 0) { statistics.incrementBytesRead(value); } return value; } catch (IOException e) { throw new FSError(e); } }
@Override public int read(byte[] b, int off, int len) throws IOException { // parameter check validatePositionedReadArgs(position, b, off, len); try { int value = fis.read(b, off, len); if (value > 0) { this.position += value; statistics.incrementBytesRead(value); } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(byte[] b, int off, int len) throws IOException { try { fos.write(b, off, len); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(int b) throws IOException { try { fos.write(b); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } } }
@Override public void write(byte[] b, int off, int len) throws IOException { try { fos.write(b, off, len); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(byte[] b, int off, int len) throws IOException { try { fos.write(b, off, len); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(int b) throws IOException { try { fos.write(b); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } } }
public int read(byte[] b, int off, int len) throws IOException { try { int value = fis.read(b, off, len); if (value > 0) { this.position += value; } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
public int read() throws IOException { try { int value = fis.read(); if (value >= 0) { this.position++; } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(int b) throws IOException { try { fos.write(b); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } } }
public void write(byte[] b, int off, int len) throws IOException { try { fos.write(b, off, len); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
public int read(byte[] b, int off, int len) throws IOException { try { int value = fis.read(b, off, len); if (value > 0) { this.position += value; } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
@Override public void write(int b) throws IOException { try { fos.write(b); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } } }
public int read() throws IOException { try { int value = fis.read(); if (value >= 0) { this.position++; } return value; } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
public void write(int b) throws IOException { try { fos.write(b); } catch (IOException e) { // unexpected exception throw new FSError(e); // assume native fs error } }
public int read(long position, byte[] b, int off, int len) throws IOException { ByteBuffer bb = ByteBuffer.wrap(b, off, len); try { return fis.getChannel().read(bb, position); } catch (IOException e) { throw new FSError(e); } }