-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrawlResultWriter.java
44 lines (39 loc) · 1.28 KB
/
CrawlResultWriter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.udacity.webcrawler.json;
import java.io.Writer;
import java.nio.file.Path;
import java.util.Objects;
/**
* Utility class to write a {@link CrawlResult} to file.
*/
public final class CrawlResultWriter {
private final CrawlResult result;
/**
* Creates a new {@link CrawlResultWriter} that will write the given {@link CrawlResult}.
*/
public CrawlResultWriter(CrawlResult result) {
this.result = Objects.requireNonNull(result);
}
/**
* Formats the {@link CrawlResult} as JSON and writes it to the given {@link Path}.
*
* <p>If a file already exists at the path, the existing file should not be deleted; new data
* should be appended to it.
*
* @param path the file path where the crawl result data should be written.
*/
public void write(Path path) {
// This is here to get rid of the unused variable warning.
Objects.requireNonNull(path);
// TODO: Fill in this method.
}
/**
* Formats the {@link CrawlResult} as JSON and writes it to the given {@link Writer}.
*
* @param writer the destination where the crawl result data should be written.
*/
public void write(Writer writer) {
// This is here to get rid of the unused variable warning.
Objects.requireNonNull(writer);
// TODO: Fill in this method.
}
}