use of com.gpcoder.gson.object.LargeData in project Java-Tutorial by gpcodervn.
the class LargeDataTypeAdapterStreamingTest method main.
public static void main(final String[] args) throws IOException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// Configure GSON
final GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LargeData.class, new LargeDataTypeAdapter());
gsonBuilder.setPrettyPrinting();
final Gson gson = gsonBuilder.create();
final LargeData data = new LargeData();
data.create(10485760);
final File dir = new File("data");
dir.mkdirs();
try (OutputStream os = new FileOutputStream(new File(dir, "outputTypeAdapterStreaming.json"));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))) {
gson.toJson(data, out);
}
stopWatch.stop();
System.out.println("Done in " + stopWatch.getTime());
}
use of com.gpcoder.gson.object.LargeData in project Java-Tutorial by gpcodervn.
the class LargeDataSerializerStreamingTest method main.
public static void main(final String[] args) throws IOException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// Configure GSON
final GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LargeData.class, new LargeDataSerializer());
gsonBuilder.setPrettyPrinting();
final Gson gson = gsonBuilder.create();
final LargeData data = new LargeData();
data.create(10485760);
final File dir = new File("data");
dir.mkdirs();
try (OutputStream os = new FileOutputStream(new File(dir, "outputSerialiserStreaming.json"));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))) {
gson.toJson(data, out);
}
stopWatch.stop();
System.out.println("Done in " + stopWatch.getTime());
}
use of com.gpcoder.gson.object.LargeData in project Java-Tutorial by gpcodervn.
the class LargeDataSerializerTest method main.
public static void main(final String[] args) throws IOException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// Configure GSON
final GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LargeData.class, new LargeDataSerializer());
gsonBuilder.setPrettyPrinting();
final Gson gson = gsonBuilder.create();
final LargeData data = new LargeData();
data.create(10485760);
final String json = gson.toJson(data);
final File dir = new File("data");
dir.mkdirs();
try (PrintStream out = new PrintStream(new File(dir, "outputSerialiser.json"), "UTF-8")) {
out.println(json);
}
stopWatch.stop();
System.out.println("Done in " + stopWatch.getTime());
}
use of com.gpcoder.gson.object.LargeData in project Java-Tutorial by gpcodervn.
the class LargeDataTypeAdapterTest method main.
public static void main(final String[] args) throws IOException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// Configure GSON
final GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LargeData.class, new LargeDataTypeAdapter());
gsonBuilder.setPrettyPrinting();
final Gson gson = gsonBuilder.create();
final LargeData data = new LargeData();
data.create(10485760);
final String json = gson.toJson(data);
final File dir = new File("data");
dir.mkdirs();
try (PrintStream out = new PrintStream(new File(dir, "outputTypeAdapter.json"), "UTF-8")) {
out.println(json);
}
stopWatch.stop();
System.out.println("Done in " + stopWatch.getTime());
}
Aggregations