@Test public void testAvailable() throws Exception { InMemoryTag tag = new InMemoryTag(FileMfUlReader.loadCardFromFile("mful_formatted.txt")); MfUlReaderWriter readerWriter = new AcrMfUlReaderWriter(tag); TagInputStream in = new TagInputStream(MemoryLayout.ULTRALIGHT, readerWriter); for (int x = 0; x < 48; x++) { assertEquals(48 - x, in.available()); in.read(); } assertEquals(0, in.available()); }
@Override public int available() throws IOException { if (currentBlock == null) { return memoryLayout.getMaxSize(); } else { return (memoryLayout.getLastDataPage() - currentPage + 1) * memoryLayout.getBytesPerPage() + (memoryLayout.getBytesPerPage() - currentByte); } }
TagInputStream extends InputStream { @Override public int available() throws IOException { if (currentBlock == null) { return memoryLayout.getMaxSize(); } else { return (memoryLayout.getLastDataPage() - currentPage + 1) * memoryLayout.getBytesPerPage() + (memoryLayout.getBytesPerPage() - currentByte); } } }
TagInputStream extends InputStream { @Override public int available() throws IOException { if (currentBlock == null) { return memoryLayout.getMaxSize(); } else { return (memoryLayout.getLastDataPage() - currentPage + 1) * memoryLayout.getBytesPerPage() + (memoryLayout.getBytesPerPage() - currentByte); } } TagInputStream(MemoryLayout memoryLayout, MfUlReaderWriter readerWriter); }
TagInputStream extends InputStream { @Override public int available() throws IOException { if (currentBlock == null) { return memoryLayout.getMaxSize(); } else { return (memoryLayout.getLastDataPage() - currentPage + 1) * memoryLayout.getBytesPerPage() + (memoryLayout.getBytesPerPage() - currentByte); } } TagInputStream(MemoryLayout memoryLayout, MfUlReaderWriter readerWriter); @Override int available(); @Override int read(); }
TagInputStream extends InputStream { @Override public int available() throws IOException { if (currentBlock == null) { return memoryLayout.getMaxSize(); } else { return (memoryLayout.getLastDataPage() - currentPage + 1) * memoryLayout.getBytesPerPage() + (memoryLayout.getBytesPerPage() - currentByte); } } TagInputStream(MemoryLayout memoryLayout, MfUlReaderWriter readerWriter); @Override int available(); @Override int read();  }