Package java.util

Examples of java.util.Scanner.ioException()


  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


        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

        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

        Scanner scanner = new Scanner(in, encoding);
        scanner.useDelimiter("\\A");
        String text = scanner.hasNext() ? scanner.next() : "";
        scanner.close();
        IOException e = scanner.ioException();
        if (e != null) {
            throw new IOException("Could not read from URL '" + url + "': " + e, e);
        }

        return text;
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

  public Function(File input) throws FileNotFoundException, CalcException {
    Scanner sc = new Scanner(input);
    try {
      init(sc);
    } finally {
      if (sc.ioException() != null) {
        System.out.println("Error when trying to read from file \"" + input.getName() + "\"");
        return;
      }
      sc.close();
    }
View Full Code Here

            functions.add(new Function());
          }
          ++count;
        }
      } finally {
        if (sc.ioException() != null) {
          System.out.println("Error when trying to read from file \"" + args[0] + "\"");
          return;
        }
        sc.close();
      }
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

        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 ioException;
                }
            }
        }
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.