88import org .schabi .newpipe .extractor .exceptions .ReCaptchaException ;
99
1010import java .io .File ;
11- import java .io .FileWriter ;
11+ import java .io .FileOutputStream ;
1212import java .io .IOException ;
13+ import java .io .OutputStreamWriter ;
14+ import java .nio .charset .StandardCharsets ;
1315import java .nio .file .Files ;
1416import java .nio .file .Path ;
1517import java .nio .file .Paths ;
1820
1921/**
2022 * <p>
21- * Relays requests to {@link DownloaderTestImpl} and saves the request/response pair into a json file.
23+ * Relays requests to {@link DownloaderTestImpl} and saves the request/response pair into a json
24+ * file.
2225 * </p>
2326 * <p>
2427 * Those files are used by {@link MockDownloader}.
@@ -44,12 +47,12 @@ class RecordingDownloader extends Downloader {
4447 * Deletes existing files starting with {@link RecordingDownloader#FILE_NAME_PREFIX}.
4548 * @param stringPath Path to the folder where the json files will be saved to.
4649 */
47- public RecordingDownloader (String stringPath ) throws IOException {
50+ public RecordingDownloader (final String stringPath ) throws IOException {
4851 this .path = stringPath ;
49- Path path = Paths .get (stringPath );
50- File folder = path .toFile ();
52+ final Path path = Paths .get (stringPath );
53+ final File folder = path .toFile ();
5154 if (folder .exists ()) {
52- for (File file : folder .listFiles ()) {
55+ for (final File file : folder .listFiles ()) {
5356 if (file .getName ().startsWith (RecordingDownloader .FILE_NAME_PREFIX )) {
5457 file .delete ();
5558 }
@@ -60,14 +63,17 @@ public RecordingDownloader(String stringPath) throws IOException {
6063 }
6164
6265 @ Override
63- public Response execute (@ Nonnull Request request ) throws IOException , ReCaptchaException {
64- Downloader downloader = DownloaderTestImpl .getInstance ();
65- Response response = downloader .execute (request );
66+ public Response execute (@ Nonnull final Request request ) throws IOException ,
67+ ReCaptchaException {
68+ final Downloader downloader = DownloaderTestImpl .getInstance ();
69+ final Response response = downloader .execute (request );
6670
67- File outputFile = new File (path + File .separator + FILE_NAME_PREFIX + index + ".json" );
71+ final File outputFile = new File (path + File .separator + FILE_NAME_PREFIX + index
72+ + ".json" );
6873 index ++;
6974 outputFile .createNewFile ();
70- FileWriter writer = new FileWriter (outputFile );
75+ final OutputStreamWriter writer = new OutputStreamWriter (new FileOutputStream (outputFile ),
76+ StandardCharsets .UTF_8 );
7177 new GsonBuilder ()
7278 .setPrettyPrinting ()
7379 .create ()
0 commit comments