Example usage for java.io PrintWriter print

List of usage examples for java.io PrintWriter print

Introduction

In this page you can find the example usage for java.io PrintWriter print.

Prototype

public void print(Object obj) 

Source Link

Document

Prints an object.

Usage

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void registrarUsuarioTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.registrarATallerUsuario(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuario param2: idTaller

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);/*from   w ww  .  j a v  a2s. c  o m*/
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void registrarDocenteTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.registrarATallerDocente(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuarioDocente param2: idTaller

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);// ww  w.  j  ava2s.  c om
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void registrarATallerDocenteByDoc(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.registrarATallerDocenteByDoc(request.getParameter("1"),
            Integer.parseInt(request.getParameter("2"))); // parameter 1: documentoDocente param2: idTaller

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);//w  ww  .  j  a  v  a 2 s  . c  o  m
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void quitarDocenteTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.abandonarTallerDocente(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); //1. idUsuario, 2. idEvento

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);// w  w w  .j a v a2 s.  c o  m
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void quitarUsuarioTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.abandonarTallerUsuario(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); //1. idUsuario, 2. idEvento

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);//from   ww  w .j av  a 2s .  c om
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void quitarUsuarioConvocatoria(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlUsuario.abandonarConvocatoria(Integer.parseInt(request.getParameter("1")), //1. idUsuario
            Integer.parseInt(request.getParameter("2"))// 2. idEvento
    );// w  w  w .j av a  2 s . c  o m

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java

protected static void registrarUsuarioConvocatoria(HttpServletRequest request, HttpServletResponse response)
        throws IOException {

    /*Enumeration<String> parameterNames = request.getParameterNames();
    String param;// w  w w. j  av a2 s .  c  o m
    while(parameterNames.hasMoreElements()){
        param = parameterNames.nextElement();
        System.out.print(param);
        System.out.print(": ");
        System.out.print(request.getParameter(param));
    }*/

    ArrayList r = CtrlUsuario.registrarAConvocatoriaUsuario(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); // parameter 1: idUsuario param2: idConv

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else {
        Util.errordeRespuesta(r, out);
    }
}

From source file:net.metanotion.sqlc.SqlcPhp.java

private static void generateStructs(final String outputFolder, final StructManager sm,
        final Set<String> implicits, final Map<String, String> implicitDocs) throws IOException {
    for (final Map.Entry<String, GetInitializer> e : sm) {
        if (!implicits.contains(e.getKey())) {
            continue;
        }/*from   ww w  .j  a  va  2s  . co m*/
        System.out.println("GENERATING " + e.getKey());
        final String docString = implicitDocs.get(e.getKey());
        final GetInitializer gi = e.getValue();

        final Struct s = (Struct) gi;
        final String[] name = e.getKey().split("\\.");
        final String[] pkg = new String[name.length - 1];
        for (int i = 0; i < pkg.length; i++) {
            pkg[i] = name[i];
        }
        final FileOutputStream fos = new FileOutputStream(mkPath(outputFolder, pkg, name[pkg.length]));
        final PrintWriter writer = new PrintWriter(new OutputStreamWriter(fos, "UTF-8"));
        writer.println("<?php");
        if (pkg.length > 0) {
            writer.print("namespace ");
            String sep = "";
            for (String pe : pkg) {
                writer.print(sep + pe);
                sep = "\\";
            }
            writer.println(";");
            writer.println("");
        }

        System.out.println("GENERATING: " + name[pkg.length]);
        writer.print("/** ");
        if (docString != null) {
            writer.println(docString.substring(3, docString.length() - 2));
        }
        writer.println("<i>This is a data/struct/value class generated by the SQLC compiler.</i> */");
        writer.println("final class " + name[pkg.length] + " {");
        for (final String p : s.listProperties()) {
            writer.print("\tpublic ");
            //writer.print(s.getType(p));
            writer.println(" $" + p + ";");
        }
        writer.println("}");
        writer.println("?>");
        writer.close();
        fos.close();
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CRUDUsuarios.java

protected static void leerUsuariosMultiplesId(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList<UsuarioEntity> usuarios = new ArrayList<>();
    usuarios = CtrlAdmin.leerMultiplesUsuarios(Integer.parseInt(request.getParameter("1")),
            Integer.parseInt(request.getParameter("2"))); // id del usuario

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();

    JSONArray list1 = new JSONArray();
    for (UsuarioEntity usuario : usuarios) {
        JSONObject obj = new JSONObject();
        obj.put("id", usuario.getIdUsuario());
        obj.put("titulo", usuario.getNombres() + " " + usuario.getApellidos());
        list1.add(obj);/*www  .  j a  va 2  s  . c om*/
    }
    out.print(list1);
}

From source file:duty_scheduler.Scheduler.java

/**
 * Prints analytics data to a space separated file called analytics.txt
 *//*from www .j  av  a  2 s . c  o  m*/
private static void printAnalytics() {
    String analyticsFile = "analytics.txt";
    PrintWriter analysisOut = null;
    try {
        analysisOut = new PrintWriter(analyticsFile);
        for (double[] generationData : analytics) {
            for (double dataPoint : generationData) {
                analysisOut.print(String.format("%.3f ", dataPoint));
            }
            analysisOut.println();
        }
    } catch (IOException e) {
        ErrorChecker.printExceptionToLog(e);
    } finally {
        analysisOut.close();
    }
}