Examples of useDelimiter()


Examples of java.util.Scanner.useDelimiter()

                                                final String token) {
        return new ExpressionAdapter() {
            public Object evaluate(Exchange exchange) {
                Object value = expression.evaluate(exchange, Object.class);
                Scanner scanner = ObjectHelper.getScanner(exchange, value);
                scanner.useDelimiter(token);
                return scanner;
            }

            @Override
            public String toString() {
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

        final Pattern pattern = Pattern.compile(regexTokenizer);
        return new ExpressionAdapter() {
            public Object evaluate(Exchange exchange) {
                Object value = expression.evaluate(exchange, Object.class);
                Scanner scanner = ObjectHelper.getScanner(exchange, value);
                scanner.useDelimiter(pattern);
                return scanner;
            }

            @Override
            public String toString() {
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

                    // -> bean=bar?method=great(a,b)
                    // http://stackoverflow.com/questions/1516090/splitting-a-title-into-separate-parts
                    delimiter = ",(?!(?:[^\\(,]|[^\\)],[^\\)])+\\))";
                }

                scanner.useDelimiter(delimiter);
                return CastUtils.cast(scanner);
            } else {
                // use a plain iterator that returns the value as is as there are only a single value
                return new Iterator<Object>() {
                    private int idx;
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

    }

    public void testGroupIterator() throws Exception {
        String s = "ABC\nDEF\nGHI\nJKL\nMNO\nPQR\nSTU\nVW";
        Scanner scanner = new Scanner(s);
        scanner.useDelimiter("\n");

        GroupIterator gi = new GroupIterator(exchange, scanner, "\n", 3);

        assertTrue(gi.hasNext());
        assertEquals("ABC\nDEF\nGHI", gi.next());
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

        byte[] buf = "\u00A31\n\u00A32\n".getBytes(StandardCharsets.UTF_8);

        ByteArrayInputStream in = new ByteArrayInputStream(buf);

        Scanner scanner = new Scanner(in, StandardCharsets.UTF_8.displayName());
        scanner.useDelimiter("\n");

        exchange.setProperty(Exchange.CHARSET_NAME, StandardCharsets.UTF_8.displayName());
        GroupIterator gi = new GroupIterator(exchange, scanner, "\n", 1);

        assertTrue(gi.hasNext());
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

    public ConnectionSettings(final String host, final int port, final String tube) {
        this.host = host;
        this.port = port;

        final Scanner scanner = new Scanner(tube);
        scanner.useDelimiter("\\+");
        final ArrayList<String> buffer = new ArrayList<String>();
        while (scanner.hasNext()) {
            final String tubeRaw = scanner.next();
            try {
                buffer.add(URLDecoder.decode(tubeRaw, "UTF-8"));
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

            connection = (HttpURLConnection) new URL(resolved).openConnection();
            connection.setRequestProperty("Cache-Control", "no-transform");
            int response = connection.getResponseCode();
            if (response == 200) {
                scanner = new Scanner(connection.getInputStream());
                scanner.useDelimiter("\\Z");
                content = scanner.next();
            }
            if (response != 200 || (content == null || content.isEmpty())) {
                for (String server : backupServers.values()) {
                    resolved = "http://" + server + "/md5/FTB2/" + url;
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

                    connection = (HttpURLConnection) new URL(resolved).openConnection();
                    connection.setRequestProperty("Cache-Control", "no-transform");
                    response = connection.getResponseCode();
                    if (response == 200) {
                        scanner = new Scanner(connection.getInputStream());
                        scanner.useDelimiter("\\Z");
                        content = scanner.next();
                        if (content != null && !content.isEmpty()) {
                            break;
                        }
                    }
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

            duration += " ";
        }
        Scanner s = new Scanner(duration);
        int res = 0;
        s.useLocale(Locale.US);//TODO LP: What to do with locale formatted numbers?
        s.useDelimiter(":");
        String val;
        while (s.hasNext()) {
            res = res * 60;
            if (s.hasNextInt()) {
                res += s.nextInt();
View Full Code Here

Examples of java.util.Scanner.useDelimiter()

    // Currently we accept pattern in list of hosts in a file
    public static List<String> parseFileList(File f) throws FileNotFoundException {
        List<String> hostList = new LinkedList<String>(), tempList;
        Host.Type type;
        Scanner s = new Scanner(f);
        s.useDelimiter("\\s+|;|,");
        String pattern = "";
        while (s.hasNext()) {
            pattern = s.next().toLowerCase().trim();
            type = isIpPattern(pattern) ? Host.Type.IP : Host.Type.HOSTNAME;
            tempList = parsePattern(pattern, type);
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.