Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 62b6e3e

Browse files
authored
Merge pull request #257 from kotvertolet/#143_implement_write_har_to_file
#143 Possibility to write HAR to file implemented as in BrowserMobProxy
2 parents d1ef357 + 063ceac commit 62b6e3e

File tree

1 file changed

+19
-0
lines changed
  • browserup-proxy-core/src/main/java/com/browserup/harreader/model

1 file changed

+19
-0
lines changed

browserup-proxy-core/src/main/java/com/browserup/harreader/model/Har.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
56

7+
import java.io.File;
8+
import java.io.IOException;
9+
import java.io.OutputStream;
10+
import java.io.Writer;
611
import java.util.Objects;
712

813
/**
@@ -13,6 +18,8 @@
1318
@JsonIgnoreProperties(ignoreUnknown = true)
1419
public class Har {
1520

21+
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
22+
1623
private HarLog log;
1724

1825
/**
@@ -41,4 +48,16 @@ public boolean equals(Object o) {
4148
public int hashCode() {
4249
return Objects.hash(log);
4350
}
51+
52+
public void writeTo(Writer writer) throws IOException {
53+
OBJECT_MAPPER.writeValue(writer, this);
54+
}
55+
56+
public void writeTo(OutputStream os) throws IOException {
57+
OBJECT_MAPPER.writeValue(os, this);
58+
}
59+
60+
public void writeTo(File file) throws IOException {
61+
OBJECT_MAPPER.writeValue(file, this);
62+
}
4463
}

0 commit comments

Comments
 (0)