Package java.io

Examples of java.io.FileOutputStream


      list.add( allcat );
     
      map.put("categories", list);


      FileOutputStream fos = null;

      try {
        //encode the data
        byte[] torrentData = BEncoder.encode(map);

         File oldFile = FileUtil.getUserFile("categories.config");
         File newFile = FileUtil.getUserFile("categories.config.new");

         //write the data out
        fos = new FileOutputStream(newFile);
        fos.write(torrentData);
         fos.flush();
         fos.getFD().sync();

          //close the output stream
         fos.close();
         fos = null;

         //delete the old file
         if ( !oldFile.exists() || oldFile.delete() ) {
            //rename the new one
            newFile.renameTo(oldFile);
         }

      }
      catch (Exception e) {
        Debug.printStackTrace( e );
      }
      finally {
        try {
          if (fos != null)
            fos.close();
        }
        catch (Exception e) {}
      }
    }finally{
     
View Full Code Here


        v.set(XMLBeans.INDEX_BEANCONNECTIONS,
            BeanConnection.getConnections(tabIndex));
        XMLBeans xml = new XMLBeans(m_beanLayout, m_bcSupport, tabIndex);
        xml.write(sFile, v);
      } /* binary */ else {
        OutputStream os = new FileOutputStream(sFile);
        ObjectOutputStream oos = new ObjectOutputStream(os);
        oos.writeObject(beans);
        oos.writeObject(BeanConnection.getConnections(tabIndex));
        oos.flush();
        oos.close();
View Full Code Here

                XMLBeans xml = new XMLBeans(m_beanLayout, m_bcSupport, XMLBeans.DATATYPE_USERCOMPONENTS,
                    m_mainKFPerspective.getCurrentTabIndex());
                xml.write(sFile2, m_userComponents);
              }
              else { */
          OutputStream os = new FileOutputStream(sFile2);
          ObjectOutputStream oos = new ObjectOutputStream(os);
          oos.writeObject(m_userComponents);
          oos.flush();
          oos.close();
          //}
View Full Code Here

     
      osw.write( fileContent );
     
      osw.close();
     
      FileOutputStream out = null;
           
      try{
       
        out = new FileOutputStream( plistFile );

          out.writebaos.toByteArray() );
 
      }finally{
       
        if( out != null ){
         
          out.close();
         
          ok = true;
        }
      }
    }finally{
View Full Code Here

        byte[] s = BuildBase.readFile(new File(source + "stylesheet.css"));
        BuildBase.writeFile(new File(target + "stylesheet.css"), s);
        String inFile = source + fileName;
        String outFile = target + fileName;
        new File(outFile).getParentFile().mkdirs();
        FileOutputStream out = new FileOutputStream(outFile);
        FileInputStream in = new FileInputStream(inFile);
        byte[] bytes = IOUtils.readBytesAndClose(in, 0);
        if (fileName.endsWith(".html")) {
            String page = new String(bytes);
            page = PageParser.parse(page, session);
            bytes = page.getBytes();
        }
        out.write(bytes);
        out.close();
    }
View Full Code Here

    }
   
    File backup = determineBackupName(dest);
    boolean backupCreated = backup != null && dest.renameTo(backup);
   
    FileOutputStream fwrite = null;
    try {
      try {
        MacCompatibility.setFileCreatorAndType(dest, "LGSM", "circ");
      } catch (IOException e) { }
      fwrite = new FileOutputStream(dest);
      file.write(fwrite, this);
      file.setName(toProjectName(dest));

      File oldFile = getMainFile();
      setMainFile(dest);
      LibraryManager.instance.fileSaved(this, dest, oldFile, file);
    } catch (IOException e) {
      if (backupCreated) recoverBackup(backup, dest);
      if (dest.exists() && dest.length() == 0) dest.delete();
      JOptionPane.showMessageDialog(parent,
        StringUtil.format(Strings.get("fileSaveError"),
          e.toString()),
        Strings.get("fileSaveErrorTitle"),
        JOptionPane.ERROR_MESSAGE);
      return false;
    } finally {
      if (fwrite != null) {
        try {
          fwrite.close();
        } catch (IOException e) {
          if (backupCreated) recoverBackup(backup, dest);
          if (dest.exists() && dest.length() == 0) dest.delete();
          JOptionPane.showMessageDialog(parent,
            StringUtil.format(Strings.get("fileSaveCloseError"),
View Full Code Here

        basePath = new File(basePath).getPath();
        try {
            if (new File(destFile).isDirectory()) {
                throw new IOException("Can't create the file as a directory with this name already exists: " + destFile);
            }
            OutputStream out = new BufferedOutputStream(new FileOutputStream(destFile));
            ZipOutputStream zipOut;
            if (jar) {
                zipOut = new JarOutputStream(out);
            } else {
                zipOut = new ZipOutputStream(out);
View Full Code Here

        reader.close();
        fragmentReader.close();

        FileInputStream fis = new FileInputStream(webXml2);
        FileOutputStream fos = new FileOutputStream(webXml);

        byte buf[] = new byte[512];
        while (true) {
            int n = fis.read(buf);
            if (n < 0) {
                break;
            }
            fos.write(buf, 0, n);
        }

        fis.close();
        fos.close();

        webXml2.delete();
        (new File(webxmlFile)).delete();

    }
View Full Code Here

        reader.close();
        fragmentReader.close();

        FileInputStream fis = new FileInputStream(webXml2);
        FileOutputStream fos = new FileOutputStream(webXml);

        byte buf[] = new byte[512];
        while (true) {
            int n = fis.read(buf);
            if (n < 0) {
                break;
            }
            fos.write(buf, 0, n);
        }

        fis.close();
        fos.close();

        if(!webXml2.delete() && log.isDebugEnabled())
            log.debug(Localizer.getMessage("jspc.delete.fail",
                    webXml2.toString()));
       
View Full Code Here

            throw ex;
        }
    }

    private Writer openWebxmlWriter(File file) throws IOException {
        FileOutputStream fos = new FileOutputStream(file);
        try {
            return webxmlEncoding != null ? new OutputStreamWriter(fos,
                    webxmlEncoding) : new OutputStreamWriter(fos);
        } catch (IOException ex) {
            fos.close();
            throw ex;
        }
    }
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.