@@ -140,7 +140,7 @@ public static void validatePomXmlFiles(final List<File> files) {
140140 String fileName = f .getName ();
141141 if ("pom.xml" .equals (fileName )) {
142142 try {
143- String fileContents = new String ( Files .readAllBytes (f .toPath ()), StandardCharsets . UTF_8 );
143+ String fileContents = Files .readString (f .toPath ());
144144 assertValidPomXml (fileContents );
145145 } catch (IOException exception ) {
146146 throw new RuntimeException (exception );
@@ -178,7 +178,7 @@ public static void validateJavaSourceFiles(List<File> files) {
178178 if (f .getName ().endsWith (".java" )) {
179179 String fileContents = "" ;
180180 try {
181- fileContents = new String ( Files .readAllBytes (f .toPath ()), StandardCharsets . UTF_8 );
181+ fileContents = Files .readString (f .toPath ());
182182 } catch (IOException ignored ) {
183183
184184 }
@@ -198,7 +198,7 @@ public static void assertValidJavaSourceCode(String javaSourceCode) {
198198
199199 public static void assertFileContains (Path path , String ... lines ) {
200200 try {
201- String generatedFile = new String ( Files .readAllBytes (path ), StandardCharsets . UTF_8 );
201+ String generatedFile = Files .readString (path );
202202 String file = linearize (generatedFile );
203203 assertNotNull (file );
204204 for (String line : lines )
@@ -215,7 +215,7 @@ public static String linearize(String target) {
215215 public static void assertFileNotContains (Path path , String ... lines ) {
216216 String generatedFile = null ;
217217 try {
218- generatedFile = new String ( Files .readAllBytes (path ), StandardCharsets . UTF_8 );
218+ generatedFile = Files .readString (path );
219219 } catch (IOException e ) {
220220 fail ("Unable to evaluate file " + path );
221221 }
@@ -227,7 +227,7 @@ public static void assertFileNotContains(Path path, String... lines) {
227227
228228 public static void assertFileNotExists (Path path ) {
229229 try {
230- new String ( Files .readAllBytes (path ), StandardCharsets . UTF_8 );
230+ Files .readString (path );
231231 fail ("File exists when it should not: " + path );
232232 } catch (IOException e ) {
233233 // File exists, pass.
@@ -237,7 +237,7 @@ public static void assertFileNotExists(Path path) {
237237
238238 public static void assertFileExists (Path path ) {
239239 try {
240- new String ( Files .readAllBytes (path ), StandardCharsets . UTF_8 );
240+ Files .readString (path );
241241 // File exists, pass.
242242 assertTrue (true );
243243 } catch (IOException e ) {
0 commit comments