List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftFileWriterUtil.java
private static void writeProviders(Set<Source> sources, PrintWriter out) { final Set<AbstractContact> all = new HashSet<AbstractContact>(); for (final Source source : sources) { all.addAll(source.getProviders()); }//from w ww.j a v a2 s.c o m for (final AbstractContact c : all) { out.print("!Sample_biomaterial_provider="); out.println(((Organization) c).getName()); } }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftFileWriterUtil.java
private static void writeProtocol(Iterable<ProtocolApplication> pas, String label, Predicate<ProtocolApplication> protocolFilter, PrintWriter out) { Iterable<ProtocolApplication> selected = pas; if (protocolFilter != null) { selected = Iterables.filter(pas, protocolFilter); }// w w w.ja v a 2 s .c o m if (selected.iterator().hasNext()) { out.print('!'); out.print(label); out.print("="); String semi = "\""; final Set<String> uniqueEntries = new HashSet<String>(); final StringBuilder sb = new StringBuilder(); for (final ProtocolApplication pa : selected) { sb.setLength(0); sb.append(pa.getProtocol().getName()); if (StringUtils.isNotBlank(pa.getProtocol().getDescription())) { sb.append(':').append(pa.getProtocol().getDescription()); } final String entry = sb.toString(); if (uniqueEntries.add(entry)) { out.print(semi); out.print(entry); semi = "\"; \""; } } out.println('"'); } }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void leerMultiplesTalleres(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList<TallerEntity> talleres = new ArrayList<>(); talleres = CtrlUsuario.leerMultiplesTalleres(Integer.parseInt(request.getParameter("1")), Integer.parseInt(request.getParameter("2"))); // posicin y tamao response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); System.out.println("Talleres: " + talleres.size()); JSONArray list1 = new JSONArray(); for (TallerEntity taller : talleres) { JSONObject obj = new JSONObject(); obj.put("id", taller.getIdTaller()); obj.put("titulo", taller.getNombre()); list1.add(obj);/* ww w. j a v a 2s . c om*/ } out.print(list1); }
From source file:dpfmanager.shell.modules.report.core.ReportGenerator.java
/** * Parse an individual report to XML format. * * @param filename the file name.// w w w . j a v a 2 s.co m * @param content the individual report. * @return the content string. */ public static void writeProcomputedIndividual(String filename, String content) { try { PrintWriter out = new PrintWriter(filename); out.print(content); out.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:io.werval.cli.DamnSmallDevShell.java
private static void printHelp(Options options, PrintWriter out) { HelpFormatter help = new HelpFormatter(); help.setOptionComparator(new OptionsComparator()); help.printUsage(out, WIDTH, "io.werval.cli [options] [command(s)]"); out.print("\n" + " The Damn Small Werval DevShell\n" + " - do not manage dependencies ;\n" + " - do not allow you to extend the build ;\n" + " - do not assemble applications.\n"); help.printWrapped(out, WIDTH, 2,/* ww w.j a v a 2 s . co m*/ "\n" + "Meaning you have to manage your application dependencies and assembly yourself. " + "Theses limitations make this DevShell suitable for quick prototyping only. " + "Prefer the Gradle or Maven build systems integration."); out.println("\n io.werval.cli is part of the Werval Development Kit - http://werval.io"); out.println("\n" + "Commands:\n\n" + " new <appdir> Create a new skeleton application in the 'appdir' directory.\n" + " secret Generate a new application secret.\n" + " clean Delete devshell temporary directory, see 'tmpdir' option.\n" + " devshell Run the Application in development mode.\n" + " start Run the Application in production mode.\n" + "\n" + " If no command is specified, 'start' is assumed."); out.println("\n" + "Options:" + "\n"); help.printOptions(out, WIDTH, options, 2, 2); help.printWrapped(out, WIDTH, 2, "\n" + "All paths are relative to the current working directory, " + "except if they are absolute of course."); help.printWrapped(out, WIDTH, 2, "\n" + "Licensed under the Apache License Version 2.0, http://www.apache.org/licenses/LICENSE-2.0"); out.println(); }
From source file:com.abstratt.mdd.frontend.textuml.renderer.TextUMLRenderingUtils.java
public static void renderStereotypeApplications(PrintWriter writer, NamedElement element, boolean newLine) { List<EObject> applications = element.getStereotypeApplications(); if (applications.isEmpty()) return;//from w ww . j a v a2 s. com StringBuilder builder = new StringBuilder(); builder.append("["); for (EObject application : applications) { renderStereotypeApplication(element, builder, application); builder.append(", "); } builder.delete(builder.length() - 2, builder.length()); builder.append("]"); writer.print(builder); if (newLine) writer.println(); else writer.print(' '); }
From source file:me.ywork.ticket.suite.controller.DingServiceController.java
/** * ??/*ww w .j a va 2 s. c o m*/ */ private static void doSuccessResponse(DingTalkEncryptor dingTalkEncryptor, HttpServletResponse response, String encryptStr, String msgSignature, String timeStamp, String nonceStr) { try { Long longTime = Long.parseLong(timeStamp); Map<String, String> jsonMap = dingTalkEncryptor.getEncryptedMap(encryptStr, longTime, nonceStr); PrintWriter printWriter = response.getWriter(); printWriter.print(JSONObject.toJSONString(jsonMap)); printWriter.close(); printWriter = null; } catch (Exception e) { logger.error("doSuccessResponse", e); } }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftFileWriterUtil.java
private static void writeMaterialTypes(Set<Extract> extracts, Set<LabeledExtract> les, PrintWriter out) { final Set<Term> all = new TreeSet<Term>(ENTITY_COMPARATOR); for (final Extract e : extracts) { addIgnoreNull(all, e.getMaterialType()); }/*from w w w.ja v a 2s .c om*/ if (all.isEmpty()) { for (final LabeledExtract e : les) { addIgnoreNull(all, e.getMaterialType()); } } for (final Term mt : all) { out.print("!Sample_molecule="); final String m = translateMaterial(mt); out.println(m); } }
From source file:de.tudarmstadt.lt.seg.app.Segmenter.java
public static void split_and_tokenize(Reader reader, String docid, ISentenceSplitter sentenceSplitter, ITokenizer tokenizer, int level_filter, int level_normalize, boolean merge_types, boolean merge_tokens, String separator_sentence, String separator_token, String separator_desc, PrintWriter writer) { try {/*w w w . j av a2 s .c o m*/ final StringBuffer buf = new StringBuffer(); // used for checking of stream is empty; take care when not running sequentially but in parallel! sentenceSplitter.init(reader).stream().sequential().forEach(sentence_segment -> { if (DEBUG) { writer.format("%s%s", docid, separator_desc); writer.println(sentence_segment.toString()); writer.print(separator_sentence); } if (sentence_segment.type != SegmentType.SENTENCE) return; tokenizer.init(sentence_segment.asString()); Stream<String> tokens = null; if (DEBUG) tokens = tokenizer.stream().map(x -> x.toString() + separator_token); else tokens = StreamSupport.stream(tokenizer .filteredAndNormalizedTokens(level_filter, level_normalize, merge_types, merge_tokens) .spliterator(), false).map(x -> x + separator_token); Spliterator<String> spliterator = tokens.spliterator(); tokens = StreamSupport.stream(spliterator, false); buf.setLength(0); boolean empty = !spliterator.tryAdvance(x -> { buf.append(x); }); if (empty) return; synchronized (writer) { // writer.write(Thread.currentThread().getId() + "\t"); writer.format("%s%s", docid, separator_desc); writer.print(buf); tokens.forEach(writer::print); writer.print(separator_sentence); writer.flush(); } }); } catch (Exception e) { Throwable t = e; while (t != null) { System.err.format("%s: %s%n", e.getClass(), e.getMessage()); t = e.getCause(); } } }
From source file:de.escidoc.core.aa.servlet.Login.java
/** * Writes the provided page content to the writer of the {@link HttpServletResponse}. The http status code is set to * the provided value.// w ww. j a v a 2 s .c o m * * @param response The {@link HttpServletResponse}. * @param page The page to write. * @param statusCode The http status code to set. * @throws IOException Thrown in case of a failed i/o operation. */ private static void sendResponse(final HttpServletResponse response, final String page, final int statusCode) throws IOException { final PrintWriter writer = response.getWriter(); writer.print(page); response.setStatus(statusCode); }