All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.wglanzer.annosave.impl.AnnoWriter Maven / Gradle / Ivy

There is a newer version: 1.2.4
Show newest version
package com.github.wglanzer.annosave.impl;

import com.github.wglanzer.annosave.impl.structure.SAnnotationContainer;
import com.github.wglanzer.annosave.impl.util.GsonUtil;
import com.google.gson.Gson;

import java.io.*;

/**
 * Writer for annotations
 *
 * @author W.Glanzer, 13.09.2017
 */
public class AnnoWriter
{

  private final OutputStream stream;

  public AnnoWriter(OutputStream pStream)
  {
    stream = pStream;
  }

  public void write(SAnnotationContainer pContainer)
  {
    Gson gson = GsonUtil.createGson();
    String jsonString = gson.toJson(pContainer);

    try(OutputStreamWriter writer = new OutputStreamWriter(stream))
    {
      writer.write(jsonString);
    }
    catch (IOException ex)
    {
      throw new RuntimeException(ex);
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy