1010import java .io .IOException ;
1111import java .io .UncheckedIOException ;
1212import java .nio .file .Files ;
13+ import java .nio .file .Path ;
1314import java .nio .file .Paths ;
1415
1516import javax .annotation .Nonnull ;
@@ -40,28 +41,30 @@ class RecordingDownloader extends Downloader {
4041 "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\ .){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" ;
4142
4243 private int index = 0 ;
43- private final String path ;
44+ private final Path path ;
4445
4546 /**
4647 * Creates the folder described by {@code stringPath} if it does not exist.
4748 * Deletes existing files starting with {@link RecordingDownloader#FILE_NAME_PREFIX}.
4849 * @param stringPath Path to the folder where the json files will be saved to.
4950 */
5051 public RecordingDownloader (final String stringPath ) {
51- this .path = stringPath ;
52- final var path = Paths . get ( stringPath );
52+ this .path = Paths . get ( stringPath ) ;
53+
5354 if (Files .exists (path )) {
5455 try (final var directoryStream = Files .newDirectoryStream (path ,
5556 entry -> entry .getFileName ().toString ()
5657 .startsWith (RecordingDownloader .FILE_NAME_PREFIX ))) {
57- for (final var entry : directoryStream ) {
58+ for (final Path entry : directoryStream ) {
5859 Files .delete (entry );
5960 }
61+ } catch (final IOException ioe ) {
62+ throw new UncheckedIOException (ioe );
6063 }
6164 } else {
6265 try {
6366 Files .createDirectories (path );
64- } catch (IOException e ) {
67+ } catch (final IOException e ) {
6568 throw new UncheckedIOException (e );
6669 }
6770 }
@@ -80,7 +83,7 @@ public Response execute(@Nonnull final Request request) throws IOException,
8083 response .latestUrl ()
8184 );
8285
83- final var outputPath = Paths . get ( path ) .resolve (FILE_NAME_PREFIX + index + ".json" );
86+ final Path outputPath = path .resolve (FILE_NAME_PREFIX + index + ".json" );
8487 index ++;
8588 try (final var writer = Files .newBufferedWriter (outputPath )) {
8689 new GsonBuilder ()
0 commit comments