1
2
3
4
5
6
7
8
9
10
11
12
13 package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocmethod;
14
15 import java.io.BufferedReader;
16 import java.io.FileReader;
17 import java.io.IOException;
18 import java.util.Scanner;
19 import java.util.function.Function;
20
21 public class InputJavadocMethodIgnoreThrowsTwo {
22
23
24
25
26
27
28 private static void ignoreTryWithResources(String input) {
29 try (BufferedReader in = new BufferedReader(new FileReader(input))) {
30 String s = in.readLine();
31 System.out.println(s);
32 if (s.length() == 0) {
33
34 throw new IllegalArgumentException("empty input");
35 }
36 else {
37 throw new IOException();
38 }
39 } catch (IOException e) {
40 System.out.println("Error reading file");
41 }
42 }
43
44
45
46
47 private static void keepTryWithoutCatch() {
48 try (Scanner sc = new Scanner(System.in)) {
49 if (sc.nextInt() <= 0) {
50
51 throw new IllegalArgumentException("");
52 }
53 }
54 }
55
56
57
58
59
60
61 void dfs(String str) {
62 class DFS {
63 void neverCalled() {
64 throw new IllegalStateException("");
65 }
66
67 void dfs(String str) {
68 if (str != null) {
69 dfs(str.toLowerCase());
70 System.out.println(str);
71 dfs(str.toUpperCase());
72 }
73 }
74 }
75 new DFS().dfs(str);
76 }
77
78
79
80
81
82
83 Runnable ignoreAnonClasses() {
84 return new Runnable() {
85 @Override
86 public void run() {
87 throw new UnsupportedOperationException("");
88 }
89 };
90 }
91
92
93
94
95
96
97
98 Function<String, Integer> lambdaInCatchBlock(String s) {
99 try {
100 int value = Integer.parseInt(s);
101 if (value <= 0) {
102 throw new NumberFormatException(value + " is negative/zero");
103 }
104 return x -> value;
105 } catch (NumberFormatException ex) {
106 if (s.length() == 1) {
107
108 throw new IllegalArgumentException("Invalid number", ex);
109 }
110 return x -> {
111 throw new UnsupportedOperationException("");
112 };
113 }
114 }
115 }