private ParserResult read( InputStream source, int readBufferSize, CompactCalendar startDate, File file, List<NavigationFormat> formats) throws IOException { log.fine( "Reading '" + source + "' with a buffer of " + readBufferSize + " bytes by " + formats.size() + " formats"); NotClosingUnderlyingInputStream buffer = new NotClosingUnderlyingInputStream(new BufferedInputStream(source)); buffer.mark(readBufferSize + 1); try { ParserContext<BaseRoute> context = new InternalParserContext<>(file, startDate); internalRead(buffer, formats, context); return createResult(context); } finally { //noinspection ThrowFromFinallyBlock buffer.closeUnderlyingInputStream(); } }
public void parse(String urlString) throws IOException { // replace CWD with current working directory for easier testing urlString = urlString.replace("CWD", new File(".").getCanonicalPath()).replace(separatorChar, '/'); URL url = new URL(urlString); int readBufferSize = getSize(url); log.info("Reading '" + url + "' with a buffer of " + readBufferSize + " bytes"); NotClosingUnderlyingInputStream buffer = new NotClosingUnderlyingInputStream(new BufferedInputStream(url.openStream())); buffer.mark(readBufferSize + 1); try { CompactCalendar startDate = extractStartDate(url); internalSetStartDate(startDate); internalRead(buffer, getNavigationFormatRegistry().getReadFormats(), this); } finally { //noinspection ThrowFromFinallyBlock buffer.closeUnderlyingInputStream(); } }