View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0
2   
3   import java.io.BufferedWriter; //indent:0 exp:0
4   import java.io.IOException; //indent:0 exp:0
5   import java.nio.charset.Charset; //indent:0 exp:0
6   import java.nio.charset.MalformedInputException; //indent:0 exp:0
7   import java.nio.charset.StandardCharsets; //indent:0 exp:0
8   import java.nio.file.DirectoryStream; //indent:0 exp:0
9   import java.nio.file.Files; //indent:0 exp:0
10  import java.nio.file.Path; //indent:0 exp:0
11  import java.nio.file.Paths; //indent:0 exp:0
12  import java.util.zip.ZipFile; //indent:0 exp:0
13  
14  public final class InputIndentationTryWithResourcesStrict { //indent:0 exp:0
15  
16      private InputIndentationTryWithResourcesStrict() { //indent:4 exp:4
17  
18      } //indent:4 exp:4
19  
20      static void fooMethod(String zipFileName) throws IOException { //indent:4 exp:4
21  
22          Charset charset = StandardCharsets.US_ASCII; //indent:8 exp:8
23          Path outputFilePath = Paths.get(zipFileName); //indent:8 exp:8
24  
25          try ( //indent:8 exp:8
26  final BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset); //indent:0 exp:12 warn
27              ZipFile zf = new ZipFile(zipFileName) //indent:12 exp:12
28               ) { //indent:13 exp:8,12 warn
29              zf.getName(); //indent:12 exp:12
30          } //indent:8 exp:8
31          try ( //indent:8 exp:8
32              BufferedWriter writer = Files. //indent:12 exp:12
33  newBufferedWriter(outputFilePath, charset); //indent:0 exp:16 warn
34              ZipFile zf = new ZipFile(zipFileName) //indent:12 exp:12
35          ) { //indent:8 exp:8,12
36              zf.getName(); //indent:12 exp:12
37          } //indent:8 exp:8
38          try (BufferedWriter writer = Files. //indent:8 exp:8
39  newBufferedWriter(outputFilePath, charset); //indent:0 exp:12 warn
40              ZipFile zf = new ZipFile(zipFileName) //indent:12 exp:12
41              ) { //indent:12 exp:8,12
42              zf.getName(); //indent:12 exp:12
43          } //indent:8 exp:8
44          try ( //indent:8 exp:8
45              BufferedWriter writer = Files. //indent:12 exp:12
46                  newBufferedWriter(outputFilePath, charset); //indent:16 exp:16
47              ZipFile zf = new ZipFile(zipFileName) //indent:12 exp:12
48              ) { //indent:12 exp:8,12
49              zf.getName(); //indent:12 exp:12
50          } //indent:8 exp:8
51          try ( //indent:8 exp:8
52              BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset); //indent:12 exp:12
53              ZipFile zf = new ZipFile(zipFileName) //indent:12 exp:12
54              ) { //indent:12 exp:8,12
55              zf.getName(); //indent:12 exp:12
56          } //indent:8 exp:8
57          try { //indent:8 exp:8
58              try ( //indent:12 exp:12
59                      BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset)) { //indent:20 exp:16 warn
60                  writer.flush(); //indent:16 exp:16
61              } catch (MalformedInputException e) { //indent:12 exp:8,12
62                  //Empty //indent:16 exp:16
63              } //indent:12 exp:12
64          } catch (IOException e) { //indent:8 exp:8
65              Integer.parseInt("1"); //indent:12 exp:12
66          } //indent:8 exp:8
67          try { //indent:8 exp:8
68  
69          } catch (Exception e) { //indent:8 exp:8
70  
71          } //indent:8 exp:8
72          try (BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset)) { //indent:8 exp:8
73              Integer.parseInt("2"); //indent:12 exp:12
74          } catch (Exception e) { //indent:8 exp:8
75  
76          } //indent:8 exp:8
77          BufferedWriter writ = Files.newBufferedWriter(outputFilePath, charset); //indent:8 exp:8
78          try (BufferedWriter writer = writ) { //indent:8 exp:8
79              Integer.parseInt("2"); //indent:12 exp:12
80          } catch (IOException e) { //indent:8 exp:8
81              throw e; //indent:12 exp:12
82          } //indent:8 exp:8
83          try              (   BufferedWriter writer = //indent:8 exp:8
84                     writ) { //indent:19 exp:12 warn
85              Integer.parseInt("2"); //indent:12 exp:12
86          } catch (IOException e) { //indent:8 exp:8
87              throw e; //indent:12 exp:12
88          } //indent:8 exp:8
89          try ( //indent:8 exp:8
90              BufferedWriter writer = //indent:12 exp:12
91                     writ) { //indent:19 exp:16 warn
92              Integer.parseInt("2"); //indent:12 exp:12
93          } catch (IOException e) { //indent:8 exp:8
94              throw e; //indent:12 exp:12
95          } //indent:8 exp:8
96          try ( //indent:8 exp:8
97              BufferedWriter writer = //indent:12 exp:12
98                       writ) { //indent:21 exp:16 warn
99              Integer.parseInt("2"); //indent:12 exp:12
100         } catch (IOException e) { //indent:8 exp:8
101             throw e; //indent:12 exp:12
102         } //indent:8 exp:8
103         try ( //indent:8 exp:8
104             BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset); //indent:12 exp:12
105             ZipFile zf = new ZipFile( //indent:12 exp:12
106                 zipFileName) //indent:16 exp:16
107             ) { //indent:12 exp:8,12
108             zf.getName(); //indent:12 exp:12
109         } //indent:8 exp:8
110         try ( //indent:8 exp:8
111             BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset); //indent:12 exp:12
112             ZipFile zf = new ZipFile( //indent:12 exp:12
113                  zipFileName) //indent:17 exp:16 warn
114             ) { //indent:12 exp:8,12
115             zf.getName(); //indent:12 exp:12
116         } //indent:8 exp:8
117         try ( //indent:8 exp:8
118             BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset); //indent:12 exp:12
119             ZipFile zf = new ZipFile( //indent:12 exp:12
120                zipFileName) //indent:15 exp:16 warn
121             ) { //indent:12 exp:8,12
122             zf.getName(); //indent:12 exp:12
123         } //indent:8 exp:8
124         try (BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset)) { //indent:8 exp:8
125             writer.close();  //indent:12 exp:12
126         } //indent:8 exp:8
127         try (          BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset)) { //indent:8 exp:8
128             writer.close();  //indent:12 exp:12
129         } //indent:8 exp:8
130        try ( //indent:7 exp:8 warn
131 
132 
133 
134             BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset)) { //indent:12 exp:12
135                writer.close();  //indent:15 exp:12 warn
136         } //indent:8 exp:8
137         try ( //indent:8 exp:8
138 
139 
140 
141            BufferedWriter writer = Files.newBufferedWriter(outputFilePath, charset)) { //indent:11 exp:12 warn
142          writer.close();  //indent:9 exp:12 warn
143         } //indent:8 exp:8
144         try ( //indent:8 exp:8
145 
146            BufferedWriter writer = Files. //indent:11 exp:12 warn
147            newBufferedWriter(outputFilePath, charset)) { //indent:11 exp:16 warn
148              writer.close(); //indent:13 exp:12 warn
149         } //indent:8 exp:8
150        try (BufferedWriter writer = writ //indent:7 exp:8 warn
151        ) { //indent:7 exp:8,12 warn
152         } catch (MalformedInputException e) { //indent:8 exp:8
153             throw e; //indent:12 exp:12
154         } //indent:8 exp:8
155          try (BufferedWriter writer = writ //indent:9 exp:8 warn
156             ) { //indent:12 exp:8,12
157         } catch (MalformedInputException e) { //indent:8 exp:8
158             throw e; //indent:12 exp:12
159         } //indent:8 exp:8
160         try (BufferedWriter writer = Files //indent:8 exp:8
161              .newBufferedWriter(outputFilePath, charset)//indent:13 exp:12 warn
162             ) { //indent:12 exp:8,12
163         } catch (MalformedInputException e) { //indent:8 exp:8
164             throw e; //indent:12 exp:12
165         } //indent:8 exp:8
166         try (                             BufferedWriter writer = Files //indent:8 exp:8
167            .newBufferedWriter(outputFilePath, charset)//indent:11 exp:12 warn
168             ) { //indent:12 exp:8,12
169         } catch (MalformedInputException e) { //indent:8 exp:8
170             throw e; //indent:12 exp:12
171         } //indent:8 exp:8
172         try (DirectoryStream<Path> ds = Files.newDirectoryStream(outputFilePath, //indent:8 exp:8
173             new DirectoryStream.Filter<Path>() { //indent:12 exp:12
174                 @Override //indent:16 exp:16
175                 public boolean accept(Path path) { //indent:16 exp:16
176                     return path.toString().contains(""); //indent:20 exp:20
177                 } //indent:16 exp:16
178             })) //indent:12 exp:12
179         { //indent:8 exp:8
180             for (Path p : ds) //indent:12 exp:12
181                 ; //indent:16 exp:16
182         } //indent:8 exp:8
183     } //indent:4 exp:4
184 } //indent:0 exp:0