/** * Returns the next token as a {@code byte} in the current radix. * This method may block for more input. * * @throws IllegalStateException * if this {@code Scanner} has been closed. * @throws NoSuchElementException * if input has been exhausted. * @throws InputMismatchException * if the next token can not be translated into a valid * {@code byte} value. */ public byte nextByte() { return nextByte(currentRadix); }
/** * Reads the next token from standard input, parses it as a byte, and returns the byte. * * @return the next byte on standard input * @throws NoSuchElementException if standard input is empty * @throws InputMismatchException if the next token cannot be parsed as a {@code byte} */ public static byte readByte() { try { return scanner.nextByte(); } catch (InputMismatchException e) { String token = scanner.next(); throw new InputMismatchException("attempts to read a 'byte' value from standard input, " + "but the next token is \"" + token + "\""); } catch (NoSuchElementException e) { throw new NoSuchElementException("attempts to read a 'byte' value from standard input, " + "but no more tokens are available"); } }
/** * Reads the next token from this input stream, parses it as a {@code byte}, * and returns the {@code byte}. * <p> * To read binary data, use {@link BinaryIn}. * * @return the next {@code byte} in this input stream * @throws NoSuchElementException if the input stream is empty * @throws InputMismatchException if the next token cannot be parsed as a {@code byte} */ public byte readByte() { try { return scanner.nextByte(); } catch (InputMismatchException e) { String token = scanner.next(); throw new InputMismatchException("attempts to read a 'byte' value from the input stream, " + "but the next token is \"" + token + "\""); } catch (NoSuchElementException e) { throw new NoSuchElementException("attemps to read a 'byte' value from the input stream, " + "but no more tokens are available"); } }
/** * Read and return the next byte. */ public static byte readByte() { return scanner.nextByte(); }
/** * Read and return the next byte. */ public byte readByte() { return scanner.nextByte(); }
/** * Read and return the next byte. */ public static byte readByte() { return scanner.nextByte(); }
/** * Read and return the next byte. */ public byte readByte() { return scanner.nextByte(); }
/** * Returns the next token as a {@code byte} in the current radix. * This method may block for more input. * * @throws IllegalStateException if this {@code Scanner} has been closed. * @throws NoSuchElementException if input has been exhausted. * @throws InputMismatchException if the next token can not be translated into a valid * {@code byte} value. */ public byte nextByte() { return nextByte(currentRadix); }
/** * Reads the next token from standard input, parses it as a byte, and returns the byte. * * @return the next byte on standard input * @throws NoSuchElementException if standard input is empty * @throws InputMismatchException if the next token cannot be parsed as a <tt>byte</tt> */ public static byte readByte() { return scanner.nextByte(); }
/** * Reads the next token from this input stream, parses it as a <tt>byte</tt>, * and returns the <tt>byte</tt>. * <p> * To read binary data, use {@link BinaryIn}. * * @return the next <tt>byte</tt> in this input stream */ public byte readByte() { return scanner.nextByte(); }
/** * Return the next byte from the input stream. */ public byte readByte() { return scanner.nextByte(); }
@Override public void readASCII(Scanner in) throws IOException { value = in.nextByte(); }
String si = "-128"; Scanner sc = new Scanner(si); byte d = sc.nextByte(); System.out.println(d); // -128
Scanner sc = new Scanner(inputString); int value = 0; for (int i = 0; i < 4; i++) { sc.next("\\\\x"); byte b = sc.nextByte(16); value = (value << 8) | (b & 0xff); } if (sc.hasNext()) { throw new SomeException("Unexpected stuff at the end"); }
public static void main(String[] args) throws IOException { InputStream stream = new FileInputStream("cube_mapping2.txt"); Scanner s = new Scanner(stream); List<Byte> bytes = new ArrayList<Byte>(); while (s.hasNextByte()) { bytes.add(s.nextByte()); } System.out.println(bytes); }
@Override public byte scanByte() { return getHandle().nextByte(); }
Scanner input = new Scanner(System.in); byte nextByte = 0x00; while(nextByte != 'q') { System.out.println("Enter a postive integer: "); int tableSize = input.nextInt(); printMultiplicationTable(tableSize); System.out.println("Enter q to quit, or any other key to continue... "); nextByte = input.nextByte(); }
@Override public byte scanByte() { return getHandle().nextByte(); }