View Javadoc
1
2   import java.io.BufferedReader;
3   import java.io.FileNotFoundException;
4   import java.io.FileReader;
5   import java.io.IOException;
6   import java.io.LineNumberReader;
7
8   import edu.umd.cs.findbugs.annotations.ExpectWarning;
9
10  public class UserMistakes {
11      @ExpectWarning("RE,RV")
12      public static void main(String[] args) throws IOException {
13          String name = "Mr. Ed";
14          name = name.replaceAll(".", "s.");
15          System.out.println(name);
16
17          // FIXME:FindBugs only catches this error with name.indexOf(String)
18          if (name.indexOf("s") > 0)
19              System.out.println("Yay");
20          else
21              System.out.println("Boo");
22
23          String result;
24
25          try {
26              BufferedReader findFiles = new BufferedReader(new FileReader("/mainList.txt"));
27              if (findFiles.readLine() != null)
28                  result = findFiles.readLine();
29              findFiles.close();
30          } catch (FileNotFoundException e) {
31              System.exit(7);
32              e.printStackTrace();
33          } catch (IOException e) {
34              e.printStackTrace();
35          }
36
37          LineNumberReader tmp = new LineNumberReader(new FileReader("/mainList.txt"));
38          int count = 0;
39          while (tmp.readLine() != null)
40              count++;
41
42          tmp.close();
43      }
44
45  }