List of usage examples for org.apache.commons.io IOUtils LINE_SEPARATOR
String LINE_SEPARATOR
To view the source code for org.apache.commons.io IOUtils LINE_SEPARATOR.
Click Source Link
From source file:com.alexholmes.hadooputils.io.FileUtils.java
/** * Writes the array list into a file as newline-separated lines. * * @param fs a Hadoop file system/*from www . ja v a2 s . c om*/ * @param p the file path * @return array of lines to write to the file * @throws java.io.IOException if something goes wrong */ public static void writeLines(Collection<?> lines, final FileSystem fs, final Path p) throws IOException { OutputStream stream = fs.create(p); try { IOUtils.writeLines(lines, IOUtils.LINE_SEPARATOR, stream); } finally { stream.close(); } }
From source file:edu.cornell.med.icb.io.TestTSVReader.java
/** * Test a stream that contains no tabs.//from w w w.ja v a2 s .co m */ @Test public void testNoTabs() throws IOException { final String foo = "The quick brown fox jumps over the lazy dog." + IOUtils.LINE_SEPARATOR + "How now brown cow" + IOUtils.LINE_SEPARATOR + "See Spot run. Run spot run!"; final TSVReader reader = new TSVReader(new StringReader(foo)); assertTrue(reader.hasNext()); reader.next(); assertEquals("Line should have a single token", 1, reader.numTokens()); assertEquals("The quick brown fox jumps over the lazy dog.", reader.getString()); assertTrue(reader.hasNext()); reader.next(); assertEquals("Line should have a single token", 1, reader.numTokens()); assertEquals("How now brown cow", reader.getString()); assertTrue(reader.hasNext()); reader.next(); assertEquals("Line should have a single token", 1, reader.numTokens()); assertEquals("See Spot run. Run spot run!", reader.getString()); assertFalse("Should have no lines", reader.hasNext()); }
From source file:com.huawei.streaming.cql.executor.mergeuserdefinds.AppendRule.java
/** * {@inheritDoc}//from w ww .j av a 2s .co m */ @Override public void execute(File srcFile, File distFile, String jarName) throws IOException { //??? Files.append(IOUtils.LINE_SEPARATOR, distFile, CHARSET); Files.append(IOUtils.LINE_SEPARATOR, distFile, CHARSET); Files.append(String.format(COMMENT, jarName), distFile, CHARSET); Files.append(IOUtils.LINE_SEPARATOR, distFile, CHARSET); String line = FileUtils.readFileToString(srcFile, CHARSET); Files.append(line, distFile, CHARSET); }
From source file:edu.emory.bmi.aiw.i2b2export.output.ProviderDataOutputFormatter.java
public void format(BufferedWriter writer) throws IOException { try {// w ww . j a va 2 s . c om Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { throw new AssertionError("Error parsing i2b2 metadata: " + ex); } try (Connection con = DriverManager.getConnection("jdbc:h2:mem:ProviderDataOutputFormatter")) { for (Observer provider : this.providers) { new ProviderDataRowOutputFormatter(this.config, provider, con).format(writer); writer.write(IOUtils.LINE_SEPARATOR); } } catch (SQLException ex) { throw new IOException("Error parsing i2b2 metadata: " + ex.getMessage()); } }
From source file:edu.emory.bmi.aiw.i2b2export.output.PatientDataOutputFormatter.java
public void format(BufferedWriter writer) throws IOException { try {/*from www. ja v a2s. com*/ Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { throw new AssertionError("Error parsing i2b2 metadata: " + ex); } try (Connection con = DriverManager.getConnection("jdbc:h2:mem:PatientDataOutputFormatter")) { for (Patient patient : this.patients) { new PatientDataRowOutputFormatter(getOutputConfiguration(), patient, con).format(writer); writer.write(IOUtils.LINE_SEPARATOR); } } catch (SQLException ex) { throw new IOException("Error parsing i2b2 metadata: " + ex.getMessage()); } }
From source file:io.cloudslang.content.xml.actions.ApplyXslTransformationTest.java
@Before public void setUp() throws Exception { applyXslTransformation = new ApplyXslTransformation(); xml = join(readLines(ClassLoader.getSystemResourceAsStream("applyxslres/testTransform.xml"), Charset.forName("UTF-8")), IOUtils.LINE_SEPARATOR); xsl = join(readLines(ClassLoader.getSystemResourceAsStream("applyxslres/xslTemplate.xsl"), Charset.forName("UTF-8")), IOUtils.LINE_SEPARATOR); invalidXml = join(readLines(ClassLoader.getSystemResourceAsStream("applyxslres/invalid.xml"), Charset.forName("UTF-8")), IOUtils.LINE_SEPARATOR); resultHtml = join(readLines(ClassLoader.getSystemResourceAsStream("applyxslres/result.html"), Charset.forName("UTF-8")), IOUtils.LINE_SEPARATOR); }
From source file:edu.emory.bmi.aiw.i2b2export.output.VisitDataOutputFormatter.java
public void format(BufferedWriter writer) throws IOException { try {//from w ww . jav a2s. c om Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { throw new AssertionError("Error parsing i2b2 metadata: " + ex); } try (Connection con = DriverManager.getConnection("jdbc:h2:mem:VisitDataOutputFormatter")) { for (Patient patient : this.patients) { for (Event visit : patient.getEvents()) { new VisitDataRowOutputFormatter(this.config, visit, con).format(writer); writer.write(IOUtils.LINE_SEPARATOR); } } } catch (SQLException ex) { throw new IOException("Error parsing i2b2 metadata: " + ex.getMessage()); } }
From source file:net.mikaboshi.intra_mart.tools.log_stats.parser.ExceptionLogParserV7Test.java
() throws ParseException { String logText = StringUtils.join(new String[] { "log.generating.time=Sun Nov 13 15:55:39 KST 2011", "log.level=ERROR", "log.logger.name=jp.co.intra_mart.system.javascript.imapi.ResinDataSourceConfiguraterObject", "log.id=5i0slu795nope", "log.thread.id=http-APP:localhost:8088-8088-0$312771783", "log.thread.group=main", "log.message=JNDI??(jdbc/oracle)???????", "",/*from w ww .j ava 2 s . c o m*/ "jp.co.intra_mart.foundation.database.exception.DataSourceConfigurationException: JNDI??(jdbc/oracle)???????", "\tat jp.co.intra_mart.foundation.database.ResinDataSourceConfigurater.bind(ResinDataSourceConfigurater.java:111)", "\tat jp.co.intra_mart.system.javascript.imapi.ResinDataSourceConfiguraterObject.jsFunction_bind(ResinDataSourceConfiguraterObject.java:152)" }, IOUtils.LINE_SEPARATOR); ExceptionLogParser exceptionLogParser = new ExceptionLogParserV7(new ParserParameter()); ExceptionLog log = exceptionLogParser.parse(logText); assertEquals( new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH).parse("Sun Nov 13 15:55:39 KST 2011"), log.date); assertEquals(Level.ERROR, log.level); assertEquals("jp.co.intra_mart.system.javascript.imapi.ResinDataSourceConfiguraterObject", log.logger); assertEquals("5i0slu795nope", log.logId); assertEquals("http-APP:localhost:8088-8088-0$312771783", log.thread); assertEquals("main", log.logThreadGroup); assertEquals("JNDI??(jdbc/oracle)???????", log.message); assertEquals("jp.co.intra_mart.foundation.database.exception.DataSourceConfigurationException: JNDI??(jdbc/oracle)???????", log.getFirstLineOfStackTrace()); }
From source file:com.jdom.word.playdough.android.GamePackPlayerActivity.java
public void setMessages(List<String> messages) { String message = StringUtils.join(messages, IOUtils.LINE_SEPARATOR); TextView messageView = (TextView) findViewById(R.id.messages); messageView.setText(message);//from w w w. j av a 2 s . c o m }
From source file:edu.cornell.med.icb.clustering.TestMCLClusterer.java
/** * Validate that reading from an MCL output file produces the proper number of clusters. * @throws IOException if the {@link edu.cornell.med.icb.clustering.MCLClusterer} * cannot access the reader passed to it. *//*ww w.j ava2s. com*/ @Test public void testMCLOutputFile() throws IOException { // assume that mcl was executed in the following way: // mcl inputfile.txt --abc -o outputfile.txt // where the input file was: // 0 2 0.05 // 1 3 0.30 // // this should produce two clusters [1, 3] and [2, 4] // so we're testing that the mcl output file translates correctly final int[][] expected = { { 0, 2 }, { 1, 3 } }; final Reader reader = new StringReader(expected[0][0] + "\t" + expected[0][1] + IOUtils.LINE_SEPARATOR + expected[1][0] + "\t" + expected[1][1] + IOUtils.LINE_SEPARATOR); final Clusterer clusterer = new MCLClusterer(reader); final List<int[]> clusters = clusterer.getClusters(); assertEquals("there should be 2 clusters", 2, clusters.size()); assertArrayEquals(expected[0], clusters.get(0)); assertArrayEquals(expected[1], clusters.get(1)); }