View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="RegexpSinglelineJava">
5         <!-- . matches any character, so we need to
6              escape it and use \. to match dots. -->
7         <property name="format" value="System\.out\.println"/>
8         <property name="ignoreComments" value="true"/>
9       </module>
10    </module>
11  </module>
12  */
13  package com.puppycrawl.tools.checkstyle.checks.regexp.regexpsinglelinejava;
14  
15  import java.io.FileReader;
16  import java.io.FileWriter;
17  import java.io.IOException;
18  import java.util.logging.Logger;
19  
20  // xdoc section -- start
21  class Example2 {
22  
23    private void testMethod1() {
24      int debug = 0;
25      System.out.println(""); // violation, 'Line matches the illegal pattern'
26      System.out.
27      println("");
28    }
29  
30    private void testMethod2() throws IOException {
31      FileReader in = new FileReader("path/to/input");
32      int ch = in.read();
33      while(ch != -1) {
34        System.out.print((char)ch);
35        ch = in.read();
36      }
37  
38      FileWriter out = new FileWriter("path/to/output");
39      out.write("something");
40    }
41  
42    public void testMethod3(){
43      final Logger logger = Logger.getLogger(Example2.class.getName());
44      logger.info("first");
45      logger.info("second");
46      logger.info("third");
47      System.out.println("fourth"); // violation, 'Line matches the illegal pattern'
48      logger.info("fifth");
49    }
50  }
51  // xdoc section -- end