int c = seqSource.read(); while (c != -1 && c != '/' && c != '>') c = seqSource.read(); if (c == N) c = seqSource.read(); if (c == D) c = seqSource.read(); boolean isStream = c == S && seqSource.read() == T && seqSource.read() == R && seqSource.read() == E && seqSource.read() == A && seqSource.read() == M; boolean isObj = !isStream && c == O && seqSource.read() == B && seqSource.read() == J; if (isStream || isObj) c = seqSource.read();
/** * Read one char and throw an exception if it is not the expected value. * * @param ec the char value that is expected. * @throws IOException if the read char is not the expected value or if an * I/O error occurs. */ protected void readExpectedChar(char ec) throws IOException { char c = (char) seqSource.read(); if (c != ec) { throw new IOException("expected='" + ec + "' actual='" + c + "' at offset " + seqSource.getPosition()); } }
protected void skipWhiteSpaces() throws IOException { //PDF Ref 3.2.7 A stream must be followed by either //a CRLF or LF but nothing else. int whitespace = seqSource.read(); //see brother_scan_cover.pdf, it adds whitespaces //after the stream but before the start of the //data, so just read those first while (ASCII_SPACE == whitespace) { whitespace = seqSource.read(); } if (ASCII_CR == whitespace) { whitespace = seqSource.read(); if (ASCII_LF != whitespace) { seqSource.unread(whitespace); //The spec says this is invalid but it happens in the real //world so we must support it. } } else if (ASCII_LF != whitespace) { //we are in an error. //but again we will do a lenient parsing and just assume that everything //is fine seqSource.unread(whitespace); } }
/** * This will skip all spaces and comments that are present. * * @throws IOException If there is an error reading from the stream. */ protected void skipSpaces() throws IOException { int c = seqSource.read(); // 37 is the % character, a comment while( isWhitespace(c) || c == 37) { if ( c == 37 ) { // skip past the comment section c = seqSource.read(); while(!isEOL(c) && c != -1) { c = seqSource.read(); } } else { c = seqSource.read(); } } if (c != -1) { seqSource.unread(c); } }
/** * This will read the next string from the stream. * * @return The string that was read from the stream, never null. * * @throws IOException If there is an error reading from the stream. */ protected String readString() throws IOException { skipSpaces(); StringBuilder buffer = new StringBuilder(); int c = seqSource.read(); while( !isEndOfName((char)c) && c != -1 ) { buffer.append( (char)c ); c = seqSource.read(); } if (c != -1) { seqSource.unread(c); } return buffer.toString(); }
int amountRead = seqSource.read(nextThreeBytes);
/** * Reads given pattern from {@link #seqSource}. Skipping whitespace at start and end if wanted. * * @param expectedString pattern to be skipped * @param skipSpaces if set to true spaces before and after the string will be skipped * @throws IOException if pattern could not be read */ protected final void readExpectedString(final char[] expectedString, boolean skipSpaces) throws IOException { skipSpaces(); for (char c : expectedString) { if (seqSource.read() != c) { throw new IOException("Expected string '" + new String(expectedString) + "' but missed at character '" + c + "' at offset " + seqSource.getPosition()); } } skipSpaces(); }
while( (lastByte = seqSource.read() ) != ASCII_SPACE && lastByte != ASCII_LF && lastByte != ASCII_CR &&
final int readBytes = pdfSource.read(binCharTestArr, 0, MAX_BIN_CHAR_TEST_LENGTH); boolean noBinData = true; int startOpIdx = -1;
char nextChar = (char) seqSource.read(); if (nextChar == '<') int c = seqSource.read(); while( braces > 0 && c != -1) char next = (char) seqSource.read(); switch(next) case ASCII_CR: c = seqSource.read(); while( isEOL(c) && c != -1) c = seqSource.read(); c = seqSource.read(); char digit = (char)c; if( digit >= '0' && digit <= '7' ) c = seqSource.read(); digit = (char)c; if( digit >= '0' && digit <= '7' ) c = seqSource.read();
int leftBracket = seqSource.read(); seqSource.read(); seqSource.read(); seqSource.read(); String id = "" + (char) seqSource.read() + (char) seqSource.read(); if( !id.equals( "ID" ) ) seqSource.read(); int lastByte = seqSource.read(); int currentByte = seqSource.read(); currentByte = seqSource.read(); seqSource.read();
seqSource.read(currLine);
seqSource.read(); skipSpaces(); return po;
/** * Read one char and throw an exception if it is not the expected value. * * @param ec the char value that is expected. * @throws IOException if the read char is not the expected value or if an * I/O error occurs. */ protected void readExpectedChar(char ec) throws IOException { char c = (char) seqSource.read(); if (c != ec) { throw new IOException("expected='" + ec + "' actual='" + c + "' at offset " + seqSource.getPosition()); } }