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