Package java.util

Examples of java.util.Scanner.match()


        assertNull(result);

        s = new Scanner("abcd1234test\n");
        result = s.findInLine(Pattern.compile("\\p{Lower}+"));
        assertEquals("abcd", result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        result = s.findInLine(Pattern.compile("\\p{Digit}{5}"));
        assertNull(result);
View Full Code Here


        assertEquals(4, matchResult.end());

        result = s.findInLine(Pattern.compile("\\p{Digit}{5}"));
        assertNull(result);
        try {
            matchResult = s.match();
            fail("Should throw IllegalStateException");
        } catch (IllegalStateException e) {
            // expected
        }
        assertEquals(0, matchResult.start());
View Full Code Here

        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        result = s.findInLine(Pattern.compile("\\p{Lower}+"));
        assertEquals("test", result);
        matchResult = s.match();
        assertEquals(8, matchResult.start());
        assertEquals(12, matchResult.end());

        char[] chars = new char[2048];
        Arrays.fill(chars, 'a');
View Full Code Here

        stringBuilder.append(chars);
        stringBuilder.append("1234");
        s = new Scanner(stringBuilder.toString());
        result = s.findInLine(Pattern.compile("\\p{Digit}+"));
        assertEquals("1234", result);
        matchResult = s.match();
        assertEquals(2048, matchResult.start());
        assertEquals(2052, matchResult.end());

        s = new Scanner("test");
        s.close();
View Full Code Here

        }

        s = new Scanner("test1234\n1234 test");
        result = s.findInLine(Pattern.compile("test"));
        assertEquals("test", result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        int number = s.nextInt();
        assertEquals(1234, number);
View Full Code Here

        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        int number = s.nextInt();
        assertEquals(1234, number);
        matchResult = s.match();
        assertEquals(4, matchResult.start());
        assertEquals(8, matchResult.end());

        result = s.next();
        assertEquals("1234", result);
View Full Code Here

        assertEquals(4, matchResult.start());
        assertEquals(8, matchResult.end());

        result = s.next();
        assertEquals("1234", result);
        matchResult = s.match();
        assertEquals(9, matchResult.start());
        assertEquals(13, matchResult.end());

        result = s.findInLine(Pattern.compile("test"));
        assertEquals("test", result);
View Full Code Here

        assertEquals(9, matchResult.start());
        assertEquals(13, matchResult.end());

        result = s.findInLine(Pattern.compile("test"));
        assertEquals("test", result);
        matchResult = s.match();
        assertEquals(14, matchResult.start());
        assertEquals(18, matchResult.end());
       
        s = new Scanner("test\u0085\ntest");
        result = s.findInLine("est");
View Full Code Here

        Pattern statLinePattern = Pattern.compile(regex);
        Scanner scanner = new Scanner(new File("target/statisticsLogback.log"));

        int totalCount = 0;
        while (scanner.findWithinHorizon(statLinePattern, 0) != null) {
            totalCount += Integer.parseInt(scanner.match().group(1));
        }
        assertEquals(testThreads.length * TestLoggingThread.STOP_WATCH_COUNT, totalCount);
    }
   
    public void testOverflowHandling() throws Exception {
View Full Code Here

        Pattern statLinePattern = Pattern.compile(regex);
        Scanner scanner = new Scanner(new File("target/statisticsLog.log"));

        int totalCount = 0;
        while (scanner.findWithinHorizon(statLinePattern, 0) != null) {
            totalCount += Integer.parseInt(scanner.match().group(1));
        }
        assertEquals(testThreads.length * TestLoggingThread.STOP_WATCH_COUNT, totalCount);
    }
   
    // http://jira.codehaus.org/browse/PERFFORJ-21
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.