Package java.util

Examples of java.util.Scanner.ioException()


        try {
            if (it instanceof Scanner) {
                // special for Scanner which implement the Closeable since JDK7
                Scanner scanner = (Scanner) it;
                scanner.close();
                IOException ioException = scanner.ioException();
                if (ioException != null) {
                    throw ioException;
                }
            } else if (it instanceof Closeable) {
                IOHelper.closeWithException((Closeable) it);
View Full Code Here


        public void close() throws IOException {
            if (value instanceof Scanner) {
                // special for Scanner which implement the Closeable since JDK7
                Scanner scanner = (Scanner) value;
                scanner.close();
                IOException ioException = scanner.ioException();
                if (ioException != null) {
                    throw ioException;
                }
            } else if (value instanceof Closeable) {
                // we should throw out the exception here  
View Full Code Here

                            } else if (value instanceof Scanner) {
                                // special for Scanner as it does not implement Closeable
                                Scanner scanner = (Scanner) value;
                                scanner.close();
                               
                                IOException ioException = scanner.ioException();
                                if (ioException != null) {
                                    throw new RuntimeCamelException("Scanner aborted because of an IOException!", ioException);
                                }
                            }
                        }
View Full Code Here

                if (verbose)
                    System.out.println("Line " + i + ": " + s + "\nskipped.");
            }
            i++;
        }
        IOException ex = input.ioException();
        if (ex != null)
            ex.printStackTrace(System.out);

        if (verbose)
            System.out.println( (i - 1) + " lines from " + (filename == null ? "stdin" : filename) " parsed.");
View Full Code Here

            } else if (value instanceof Scanner) {
                // special for Scanner as it does not implement Closeable
                Scanner scanner = (Scanner) value;
                scanner.close();

                IOException ioException = scanner.ioException();
                if (ioException != null) {
                    throw ioException;
                }
            }
        }
View Full Code Here

        while (scanner.hasNext()) {
            String pair = scanner.next();

            // The 'Scanner' class masks any IOExceptions that happen on '.next()', so we
            // have to check for them explicitly.
            IOException ioe = scanner.ioException();
            if (ioe != null) {
                throw new DbxException.NetworkIO(ioe);
            }

            String[] parts = pair.split("=");
View Full Code Here

            } else if (value instanceof Scanner) {
                // special for Scanner as it does not implement Closeable
                Scanner scanner = (Scanner) value;
                scanner.close();

                IOException ioException = scanner.ioException();
                if (ioException != null) {
                    throw ioException;
                }
            }
        }
View Full Code Here

        public void close() throws IOException {
            if (value instanceof Scanner) {
                // special for Scanner which implement the Closeable since JDK7
                Scanner scanner = (Scanner) value;
                scanner.close();
                IOException ioException = scanner.ioException();
                if (ioException != null) {
                    throw ioException;
                }
            } else if (value instanceof Closeable) {
                // we should throw out the exception here  
View Full Code Here

  public static String readStream(InputStream is) throws IOException {
    if(is == null) return null;
    final Scanner scanner = new Scanner(new BufferedInputStream(is), CHARSET);
    scanner.useDelimiter("\\A");
    final String content = scanner.hasNext() ? scanner.next() : "";
    final IOException readException = scanner.ioException();
    scanner.close();
    if(readException != null) {
      throw new IOException(readException);
    }
    return content;
View Full Code Here

  public static String readStream(InputStream is) throws IOException {
    if(is == null) return null;
    final Scanner scanner = new Scanner(new BufferedInputStream(is), "UTF-8");
    scanner.useDelimiter("\\A");
    final String content = scanner.hasNext() ? scanner.next() : "";
    final IOException readException = scanner.ioException();
    scanner.close();
    if(readException != null) {
      throw new IOException(readException);
    }
    return content;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.