Package java.io

Examples of java.io.FileOutputStream


        }
        if(encoding == null) {
            throw new IllegalArgumentException();
        }
        try {
            FileOutputStream out = new FileOutputStream(file, append);
            OutputStreamWriter osw = new OutputStreamWriter(out, encoding);
            this._writer = new FastBufferedWriter(osw, 16384);
        } catch (IOException e) {
            throw new IllegalStateException("failed to writer to file: " + file.getAbsolutePath(), e);
        }
View Full Code Here


* @author Olivier Chalouhi
*
*/
public class Logger {
    public static void log(String value) {
    FileOutputStream fos = null;
    try {
      String userPath = System.getProperty("user.dir") + System.getProperty("file.separator");
      File logFile = new File(userPath + "snippet.log");
      fos = new FileOutputStream(logFile,true);
      fos.write((value+"\n").getBytes());
      fos.close();
    } catch(Exception e) {
      //Do nothing
    }
  }
View Full Code Here

        XMLType xv = new XMLType(xml);
        String key = xv.getReferenceStreamId();
       
        // now force to serialize
        File saved = new File(UnitTestUtil.getTestScratchPath()+"/xmlsaved.bin"); //$NON-NLS-1$
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(saved));
        out.writeObject(xv);
        out.close();
       
        // now read back the object from serilized state
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(saved));
View Full Code Here

      saveKey(file, key);
    }
   
    private static void saveKey(String file, SecretKey key) throws CryptoException, IOException {
      ArgCheck.isNotNull(file);
      FileOutputStream fos = new FileOutputStream(file);
      try {
          KeyStore store = KeyStore.getInstance("JCEKS"); //$NON-NLS-1$
          store.load(null,null);
        store.setKeyEntry(DEFAULT_ALIAS, key, DEFAULT_STORE_PASSWORD.toCharArray(),null);
        store.store(fos, DEFAULT_STORE_PASSWORD.toCharArray());
      } catch (GeneralSecurityException e) {
        throw new CryptoException(e);
      } finally {
        fos.close();
     
    }
View Full Code Here

  }
 
 
  public static void copy(File fromFile, File toFile) throws IOException {
    FileInputStream from = null;
    FileOutputStream to = null;
    try {
      from = new FileInputStream(fromFile);
      to = new FileOutputStream(toFile);
      byte[] buffer = new byte[4096];
      int bytesRead;

      while ((bytesRead = from.read(buffer)) != -1)
        to.write(buffer, 0, bytesRead); // write
    } finally {
      if (from != null)
        try {
          from.close();
        } catch (IOException e) {
          ;
        }
      if (to != null)
        try {
          to.close();
        } catch (IOException e) {
        }
    }
  }
View Full Code Here

  public static void copyWithVariableSubstitution(File source, File target, Map<String,String> variables, String varPrefix, String varSuffix) throws IOException {
    BufferedReader reader = null;
    BufferedWriter writer = null;
    try {
      reader = new BufferedReader(new InputStreamReader(new FileInputStream(source)));
      writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(target)));
      String line = reader.readLine();
      while (line != null) {
        line = substitute(line, variables, varPrefix, varSuffix);
        writer.write(line + "\n");
        line = reader.readLine();
View Full Code Here

          if(entry.isDirectory()) {
            (new File(targetDir, entry.getName())).mkdir();
            continue;
          }
          InputStream in = zipFile.getInputStream(entry);
          OutputStream out = new FileOutputStream(new File(targetDir, entry.getName()));   
          try {
            WGUtils.inToOut(in, out, 2048);
          } finally {
            out.close();
            in.close();
          }
        }
        zipFile.close();
    } finally {
View Full Code Here

  public static final void unzip(InputStream zipIn, File targetDir) throws ZipException, IOException {
    File temp = File.createTempFile("UNZIP", null);
    temp.deleteOnExit();
   
    try {
      OutputStream out = new FileOutputStream(temp);
      try {
        WGUtils.inToOut(zipIn, out, 2048);
      } finally {
        out.close();
      }
      unzip(temp, targetDir);
    } finally {
      temp.delete();
    }
View Full Code Here

         uctx.unmarshalDocument(new FileInputStream("src/test/resources/portal/portal/classic/navigation.xml"), null);
      assertEquals(PageNavigation.class, obj.getClass());

      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream("target/navigation.xml"));

      obj = uctx.unmarshalDocument(new FileInputStream("target/navigation.xml"), null);
      assertEquals(PageNavigation.class, obj.getClass());
   }
View Full Code Here

            new FileInputStream("src/test/resources/portal/portal/classic/portlet-preferences.xml"), null);
      assertEquals(PortletPreferencesSet.class, obj.getClass());

      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream("target/portlet-preferences.xml"));
      assertEquals(PortletPreferencesSet.class, obj.getClass());
   }
View Full Code Here

TOP

Related Classes of java.io.FileOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.