List of usage examples for java.io PrintWriter println
public void println(Object x)
From source file:io.datalayer.conf.HierarchicalIniConfigurationTest.java
/** * Writes a test ini file.// w w w .j a v a 2 s . c o m * * @param content the content of the file * @throws IOException if an error occurs */ private static void writeTestFile(String content) throws IOException { PrintWriter out = new PrintWriter(new FileWriter(TEST_FILE)); try { out.println(content); } finally { out.close(); } }
From source file:i18n.Language.java
public static void sauver(String nomDuFichier) { if (jo != null) { try {/* ww w .j a va 2 s. co m*/ FileWriter fw = new FileWriter(nomDuFichier); BufferedWriter bw = new BufferedWriter(fw); PrintWriter fichierSortie = new PrintWriter(bw); fichierSortie.println(jo.toString()); fichierSortie.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:edu.umd.cs.submitServer.servlets.RunMoss.java
static private void uploadSubmission(PrintWriter writer, SocketClient socketClient, String classAccount, byte[] bytes, boolean baselline, HashSet<String> extensions) { try {// w ww .ja va 2 s .com HashSet<String> seen = new HashSet<>(); Map<String, List<String>> files = TextUtilities.scanTextFilesInZip(new ByteArrayInputStream(bytes)); for (Map.Entry<String, List<String>> e : files.entrySet()) { String name = e.getKey(); name = name.substring(name.lastIndexOf('/') + 1); int lastDot = name.lastIndexOf('.'); if (lastDot >= 0 && extensions.contains(name.substring(lastDot)) && seen.add(name)) { name = classAccount + "/" + name; writer.println(" Sending " + name); socketClient.uploadFile(name, e.getValue(), false); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.cornell.med.icb.goby.modes.TestDiscoverSequenceVariantsMode.java
@BeforeClass public static void initializeTestDirectory() throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Creating base test directory: " + BASE_TEST_DIR); }/*from w w w . j av a 2s .c om*/ FileUtils.forceMkdir(new File(BASE_TEST_DIR)); PrintWriter outTSV = new PrintWriter(statsFilename); outTSV.println( "basename\tread-index\tcount-variation-bases\tbases-at-index/all-variations-bases\tbases-at-index/all-reference-bases\tcount-reference-bases\tcount-reference-bases-at-index"); for (int i = 0; i < NUM_BASENAME_PER_GROUP * 2; i++) { basenames[i] = BASE_TEST_DIR + "/basen" + i; writeAlignment(basenames, i, 'G'); appendToStats(basenames, i, outTSV); } specificAlignments = new String[1]; // write a new alignment that is different from all others: specificAlignments[0] = BASE_TEST_DIR + "/align-specific-sample"; writeAlignment(specificAlignments, 0, 'C'); appendToStats(specificAlignments, 0, outTSV); outTSV.close(); }
From source file:net.cristcost.study.services.ServiceTestUtil.java
private static SecurityContext authenticate(PrintWriter writer, HttpServletRequest request, AuthenticationManager authenticationManager) { SecurityContext initialContext = SecurityContextHolder.getContext(); if (request.getParameter("user") != null) { UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken( request.getParameter("user"), request.getParameter("pass")); try {//from ww w . jav a2s . c o m Authentication authentication = authenticationManager.authenticate(authRequest); SecurityContextHolder.setContext(SecurityContextHolder.createEmptyContext()); SecurityContextHolder.getContext().setAuthentication(authentication); writer.println("Authenticating user: " + request.getParameter("user")); } catch (AuthenticationException e) { writer.println("! Error while Authenticating: " + e.getMessage()); } writer.println(); } return initialContext; }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftFileWriterUtil.java
private static void writeOrganism(Set<Source> sources, Set<Sample> samples, Experiment exp, PrintWriter out) { final Set<Organism> all = new TreeSet<Organism>(ENTITY_COMPARATOR); for (final Source source : sources) { addIgnoreNull(all, source.getOrganism()); }//from w w w .j av a2s. com for (final Sample sample : samples) { addIgnoreNull(all, sample.getOrganism()); } if (all.isEmpty()) { all.add(exp.getOrganism()); } for (final Organism o : all) { out.print("!Sample_organism="); out.println(o.getScientificName()); } }
From source file:marytts.util.io.FileUtils.java
public static void writeToTextFile(double[] array, String textFile) { FileWriter outFile = null;//w w w .j a v a2 s . c om PrintWriter out = null; try { outFile = new FileWriter(textFile); out = new PrintWriter(outFile); for (int i = 0; i < array.length; i++) { out.println(String.valueOf(array[i])); } } catch (IOException e) { System.out.println("Error! Cannot create file: " + textFile); } finally { close(outFile, out); } }
From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java
public static void log(DoCommand dc, String message) { Log.i("SUTAgentAndroid", message); if (SUTAgentAndroid.LogCommands == false) { return;// w ww .j a v a2 s . c o m } if (message == null) { Log.e("SUTAgentAndroid", "bad arguments in log()!"); return; } String fileDateStr = "00"; String testRoot = dc.GetTestRoot(); String datestamp = dc.GetSystemTime(); if (testRoot == null || datestamp == null) { Log.e("SUTAgentAndroid", "Unable to get testRoot or datestamp in log!"); return; } try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); Date dateStr = sdf.parse(datestamp); SimpleDateFormat sdf_file = new SimpleDateFormat("yyyy-MM-dd"); fileDateStr = sdf_file.format(dateStr); } catch (ParseException pe) { } String logFile = testRoot + "/" + fileDateStr + "-sutcommands.txt"; PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(logFile, true)); pw.println(datestamp + " : " + message); } catch (IOException ioe) { Log.e("SUTAgentAndroid", "exception with file writer on: " + logFile); } finally { if (pw != null) { pw.close(); } } }
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 .j a v a 2 s . c o m*/ 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:net.metanotion.sqlc.SQLC.java
public static int makeMethod(final PrintWriter writer, final SQLMethod m, final Statement qe, final int level, final int[] gensym, final int[] braces, final boolean retValue) { final int stmt = gensym[0]; gensym[0]++;//from ww w . j a v a2s . co m writer.println("\t\t\ttry (final java.sql.PreparedStatement _" + stmt + " = _0.prepareStatement(\"" + StringEscapeUtils.escapeJava(qe.sql.trim()) + "\")) {"); braces[0] = braces[0] + 1; for (final SQLSetter s : qe.setters) { int i = 0; for (int j = 0; j < m.pList.length; j++) { if (s.name.equals(m.pList[j])) { i = j + 1; break; } } writer.println("\t\t\t" + s.setStatic("_" + stmt, "_" + i) + ";"); } writer.println("\t\t\t_" + stmt + ".execute();"); return -1; }