Skip to content

Instantly share code, notes, and snippets.

@e-d
e-d / GsonTestClass.java
Last active January 26, 2016 21:25
Example of deserializing JSON (using GSON) to various object types based on a type embedded in the JSON object.
public class GsonTestClass {
static Gson gson = new Gson();
/* Running the main method will produce the following output:
*
* Before Serializing/Deserializing: {"foo1":"fooooo","bar1":"barrrr","type":"POJO1"}
* Before Serializing/Deserializing: {"foo2":"fooooooooooo","bar2":["bar","barr"],"type":"POJO2"}
* After Serialization (Knowing Type): {"foo1":"fooooo","bar1":"barrrr","type":"POJO1"}
* After Serialization (Knowing Type): {"foo2":"fooooooooooo","bar2":["bar","barr"],"type":"POJO2"}
* After Serialization (Type Unknown): {"foo1":"fooooo","bar1":"barrrr","type":"POJO1"}
@e-d
e-d / ScreenRecorder.java
Created January 21, 2016 17:46
Example program for capturing screen video using Xuggle Xuggler.
package com.edwardstlouis.xuggler;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.util.concurrent.Executors;