@Test public void testRead_singleByte() throws IOException { JimfsInputStream in = newInputStream(2); assertThat(in.read()).isEqualTo(2); assertEmpty(in); }
@Override public synchronized int read() throws IOException { checkNotClosed(); if (finished) { return -1; } file.readLock().lock(); try { int b = file.read(pos++); if (b == -1) { finished = true; } else { file.updateAccessTime(); } return b; } finally { file.readLock().unlock(); } }
JimfsInputStream extends InputStream { @Override public synchronized int read() throws IOException { checkNotClosed(); if (finished) { return -1; } file.readLock().lock(); try { int b = file.read(pos++); if (b == -1) { finished = true; } else { file.updateAccessTime(); } return b; } finally { file.readLock().unlock(); } } }
JimfsInputStream extends InputStream { @Override public synchronized int read() throws IOException { checkNotClosed(); if (finished) { return -1; } file.readLock().lock(); try { int b = file.read(pos++); if (b == -1) { finished = true; } else { file.updateAccessTime(); } return b; } finally { file.readLock().unlock(); } } JimfsInputStream(RegularFile file, FileSystemState fileSystemState); }
JimfsInputStream extends InputStream { @Override public synchronized int read() throws IOException { checkNotClosed(); if (finished) { return -1; } file.readLock().lock(); try { int b = file.read(pos++); if (b == -1) { finished = true; } else { file.updateAccessTime(); } return b; } finally { file.readLock().unlock(); } } JimfsInputStream(RegularFile file, FileSystemState fileSystemState); @Override synchronized int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override synchronized int available(); @Override synchronized void close(); }
JimfsInputStream extends InputStream { @Override public synchronized int read() throws IOException { checkNotClosed(); if (finished) { return -1; } file.readLock().lock(); try { int b = file.read(pos++); if (b == -1) { finished = true; } else { file.updateAccessTime(); } return b; } finally { file.readLock().unlock(); } } JimfsInputStream(RegularFile file, FileSystemState fileSystemState); @Override synchronized int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override synchronized int available(); @Override synchronized void close();  }