List of usage examples for org.apache.commons.io IOUtils write
public static void write(StringBuffer data, OutputStream output) throws IOException
StringBuffer
to bytes on an OutputStream
using the default character encoding of the platform. From source file:com.google.gwt.site.markdown.Util.java
public static void writeStringToFile(File file, String content) throws IOException { FileOutputStream fileOutputStream = null; try {//from w w w . j a v a2 s . co m fileOutputStream = new FileOutputStream(file); IOUtils.write(content, fileOutputStream); } finally { IOUtils.closeQuietly(fileOutputStream); } }
From source file:com.aestasit.markdown.BaseTest.java
protected static InputStream allTestData() throws IOException { ByteArrayOutputStream data = new ByteArrayOutputStream(); for (String fileName : allTestFiles()) { IOUtils.write(IOUtils.toString(testData(fileName)), data); }// w ww.j av a 2 s .c o m IOUtils.closeQuietly(data); return new ByteArrayInputStream(data.toByteArray()); }
From source file:es.us.isa.jdataset.writer.AbstractTextWriter.java
@Override public void write(DataSet dataset, OutputStream out) throws IOException { String result = write(dataset); IOUtils.write(result, out); }
From source file:coolmap.utils.Config.java
public static void saveConfig() { try {/*w w w. j a va 2 s . c om*/ // String workingDirectory; // workingDirectory = System.getProperty("user.dir"); // configFile = workingDirectory + File.separator + "config.json"; String savePath = getProperty(COOLMAP_DIRECTORY) + File.separator + "config.json"; IOUtils.write(getJSONConfig().toString(), new FileOutputStream(new File(savePath))); } catch (Exception e) { System.err.println("Config can not be saved"); } }
From source file:com.wisemapping.util.ZipUtils.java
public static byte[] bytesToZip(@NotNull final byte[] content) throws IOException { ZipOutputStream zip = null;/*from ww w.j av a 2 s . c o m*/ final ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); try { zip = new ZipOutputStream(byteArray); ZipEntry zEntry = new ZipEntry("content"); zip.putNextEntry(zEntry); IOUtils.write(content, zip); zip.closeEntry(); } finally { if (zip != null) { zip.flush(); zip.close(); } } return byteArray.toByteArray(); }
From source file:com.moz.fiji.mapreduce.TestingResources.java
/** * Writes a text file./*from ww w . j av a 2 s.c o m*/ * * @param path Path of the file to write. * @param content Text content of the file to create. * @throws IOException on I/O error. */ public static void writeTextFile(final File path, final String content) throws IOException { final FileOutputStream ostream = new FileOutputStream(path); try { IOUtils.write(content, ostream); } finally { ostream.close(); } }
From source file:com.pullup.app.util.ImageUtils.java
public String saveImage(InputStream stream, String token) { byte[] bytes = null; String path = "C:\\pullup\\profile\\" + token + ".png"; try {// w w w. j a v a 2 s .c om bytes = IOUtils.toByteArray(stream); log.info("Saving image"); IOUtils.write(token, new FileWriter(new File(path))); } catch (IOException ex) { log.severe("Could not write image: " + ex.getMessage()); } return path; }
From source file:de.tudarmstadt.ukp.dkpro.tc.svmhmm.util.SVMHMMUtilsTest.java
@Test public void testExtractComments() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); IOUtils.write("O qid:5 2:7 # #IFTHEN O 5", outputStream); InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); List<List<String>> comments = SVMHMMUtils.extractComments(inputStream); assertEquals(1, comments.size());//w w w . j a v a 2 s. co m assertEquals("#IFTHEN", comments.get(0).get(0)); assertEquals("O", comments.get(0).get(1)); assertEquals("5", comments.get(0).get(2)); }
From source file:applica.framework.licensing.LicenseManager.java
public void generateLicenseFile(String user, Date validity, String path) throws LicenseGenerationException { License license = new License(user, validity); license.generate();// ww w . j a v a 2 s . c o m FileOutputStream out = null; try { out = new FileOutputStream(path); IOUtils.write(license.getBytes(), out); } catch (FileNotFoundException e) { throw new LicenseGenerationException(e); } catch (IOException e) { throw new LicenseGenerationException(e); } finally { if (out != null) { IOUtils.closeQuietly(out); } } }
From source file:io.ingenieux.lambada.invoker.fixtures.Fixture.java
public void doSomethingRaw(InputStream is, OutputStream os) throws Exception { Integer value = Integer.valueOf(IOUtils.toString(is)); IOUtils.write("" + (2 * value), os); }