package com.cftech.core.util;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class OutputJSONUtil 
{
	
	public static void convertoJSONStream(HttpServletResponse response,
			String json) 
	{
		response.setCharacterEncoding("utf-8");
		response.setContentType("application/json");
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
			pw.print(json);
			pw.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (pw != null)
				pw.close();
		}
	}
	
	
	public static void convertoHtmlStream(HttpServletResponse response,
			String json) 
	{
		response.setCharacterEncoding("utf-8");
		PrintWriter pw = null;
		try {
			pw = response.getWriter();
			pw.print(json);
			pw.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (pw != null)
				pw.close();
		}
	}
}
