Code example for StringWriter

Methods: closetoString

0
 
  public static String generateRegisterResponse(RegisterResponseEntry... entries)
      throws JsonGenerationException, JsonMappingException, IOException 
  { 
    ObjectMapper mapper = new ObjectMapper();
    StringWriter w = new StringWriter();
    mapper.writeValue(w, entries);
    w.close();
    return w.toString();
  } 
 
  public static String generateRegisterResponseV4(HashMap<String, List<Object>> entries)
      throws JsonGenerationException, JsonMappingException, IOException 
  { 
    ObjectMapper mapper = new ObjectMapper();
    StringWriter w = new StringWriter();
    mapper.writeValue(w, entries);
    w.close();
    return w.toString();
  } 
Stop searching for code, let great code find you!  Add Codota to your java IDE