### Question:
JimfsInputStream extends InputStream { @Override public synchronized int available() throws IOException { checkNotClosed(); if (finished) { return 0; } long available = Math.max(file.size() - pos, 0); return Ints.saturatedCast(available); } 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();  }### Answer:
@Test public void testAvailable() throws IOException { JimfsInputStream in = newInputStream(1, 2, 3, 4, 5, 6, 7, 8); assertThat(in.available()).isEqualTo(8); assertThat(in.read()).isEqualTo(1); assertThat(in.available()).isEqualTo(7); assertThat(in.read(new byte[3])).isEqualTo(3); assertThat(in.available()).isEqualTo(4); assertThat(in.read(new byte[10], 1, 2)).isEqualTo(2); assertThat(in.available()).isEqualTo(2); assertThat(in.read(new byte[10])).isEqualTo(2); assertThat(in.available()).isEqualTo(0); }