Package java.io

Examples of java.io.FileOutputStream


    managers.addAttribute("members", "designer");

    XMLWriter writer = null;
    try {
      writer = new XMLWriter(OutputFormat.createPrettyPrint());
      writer.setOutputStream(new FileOutputStream(new File(getWGABase().getLocation().toFile(), "auth.xml")));
      writer.write(auth);
    } catch (Exception e) {
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to generate default auth configuration.", e));
    } finally {
      try {
        if (writer != null) {
          writer.close();
        }
      } catch (IOException e) {
      }
    }
    FileOutputStream configFileStream = null;
    try {
      _config = WGARuntimeConfiguration.createDefaultConfig();
      synchronized (_wgaConfigLock) {
        configFileStream = new FileOutputStream(getConfigFile().getLocation().toFile());
        WGARuntimeConfiguration.write(_config, configFileStream);
      }
    } catch (Exception e) {
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to generate default runtime configuration.", e));
    } finally {
      if (configFileStream != null) {
        try {
          configFileStream.close();
        } catch (IOException e) {
        }
      }

    }
View Full Code Here


  public void saveWGAConfig(WGAConfiguration config) throws IOException {

    synchronized (_wgaConfigLock) {

      FileOutputStream wgaxmlstream = null;
      try {
          IFile wgaConfig = getWGABase().getFile(new Path("wgaconfig.xml"));
          if (wgaConfig.exists() && wgaConfig.isReadOnly()) {
                    ResourceAttributes attributes = wgaConfig.getResourceAttributes();
                    attributes.setReadOnly(false);
                    wgaConfig.setResourceAttributes(attributes);               
          }
        wgaxmlstream = new FileOutputStream(wgaConfig.getLocation().toFile());
        WGAConfiguration.write(config, wgaxmlstream);
        _wgaBase.refreshLocal(IResource.DEPTH_ONE, null);
      } catch (Exception e) {
        IOException ioe = new IOException("Unable to save wga configuration.");
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
      } finally {
        if (wgaxmlstream != null) {
          try {
            wgaxmlstream.close();
          } catch (IOException e) {
          }
        }
      }
View Full Code Here

  public WGARuntimeConfiguration getConfiguration() {
    return _config;
  }

  public void flushConfig() throws CoreException {
    FileOutputStream configFileStream = null;
    try {
      IFile configFile = getConfigFile();
      if (configFile.isReadOnly()) {
        ResourceAttributes attributes = configFile.getResourceAttributes(); // ResourceAttributes.fromFile(configFile.getLocation().toFile());
        attributes.setReadOnly(false);
        configFile.setResourceAttributes(attributes);
      }

      // we might have to update root url bc. of distribution changes
      if (getRootURL() != null) {
        WGAConfiguration wgaConfig = retrieveWGAConfig(false);
        if (wgaConfig != null) {
          wgaConfig.getServerOptions().put(WGAConfiguration.SERVEROPTION_ROOT_URL, getRootURL().toString());
          saveWGAConfig(wgaConfig);
        }
      }
      configFileStream = new FileOutputStream(configFile.getLocation().toFile());
      WGARuntimeConfiguration.write(_config, configFileStream);

      _project.refreshLocal(IResource.DEPTH_ONE, null);
    } catch (Exception e) {
      WGADesignerPlugin.getDefault().logError("Unable to save config of runtime '" + getName() + "'.", e);
      throw new CoreException(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to save config of runtime '" + getName() + "'.", e));
    } finally {
      try {
        if (configFileStream != null) {
          configFileStream.close();
        }
      } catch (IOException e) {

      }
    }
View Full Code Here

                question, question, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (ret == JOptionPane.YES_OPTION) {
            File storageFile = appSettings.getStorageFile();
            try {
                new XmlExport(dataPool, dataSettings,
                        new FileOutputStream(storageFile)).doWork();
                logger.info("Auto-export to:" + storageFile);
            } catch (Exception ex) {
                logger.fatal("Couldn't auto-export to:" + storageFile, ex);
                getApplication().getActiveWindow().getStatusBar().
                        setErrorMessage("Couldn't import from " + storageFile
View Full Code Here

    if (response == SWT.YES) {

      SortedProperties sortedProperties = new SortedProperties();
      sortedProperties.putAll(_props);
      FileOutputStream labelFileStream = null;
      try {
        labelFileStream = new FileOutputStream(_file.getLocation().toString());
        sortedProperties.store(labelFileStream, null);
        _file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
      } catch (IOException e) {
        WGADesignerPlugin.getDefault().logInfo("Unable to store file: " + _file.getLocation(), e);
      } catch (CoreException e) {
        WGADesignerPlugin.getDefault().logInfo("Unable to refresh resource on: " + _file.getLocation(), e);
      } finally {
        try {
          labelFileStream.close();
        } catch (IOException e) {
          WGADesignerPlugin.getDefault().logInfo("Unable to close FileOutputStream for: " + _file.getLocation(), e);
        }
      }
    }
View Full Code Here

    new Thread() {
      public void run() {   
        try {
          Model model = ModelFactory.createDefaultModel();
          model.read(result.in,"");
          OutputStream out = new FileOutputStream("test18-m"+modelOrdinal+".rdf");
          model.write(out, "");
          out.close();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    }.start();
View Full Code Here

     * @param header
     * @throws IOException
     * @since 4.3
     */
    public static void print(String fileName, Properties props, String header) throws IOException {
        FileOutputStream stream = null;
        try {
            stream = new FileOutputStream(fileName);
            props.store(stream, header);
            stream.flush();
        } finally {
            try {
                if (stream != null) {
                    stream.close();
                }
            } catch (Exception e) {
            }
        }
    }
View Full Code Here

     * with the specified header. 
     * Results are sorted by property name.
     */   
    public static void print( String fileName, Properties props ) throws IOException {

        FileOutputStream stream = null;
        PrintStream writer = null;

        try {

        stream = new FileOutputStream(fileName);
          writer = new PrintStream(stream);
   
            List names = new ArrayList();
            Enumeration enumeration = props.propertyNames();
            while ( enumeration.hasMoreElements() ) {
                String name = (String) enumeration.nextElement();
                names.add(name);
            }
            Collections.sort(names);
   
            StringBuffer sb;
   
            for (Iterator nIt=names.iterator(); nIt.hasNext(); ) {
              String name = (String) nIt.next();
   
              String value = props.getProperty(name);
   
              sb = new StringBuffer();
   
              sb.append(name);
              sb.append("="); //$NON-NLS-1$
              sb.append(value);
   
              writer.println(sb.toString());
            }
            writer.flush();
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (Exception e){
                               
            }
            try {
                if (stream != null) {
                    stream.close();
                }
            } catch (Exception e){
                               
            }           
        }
View Full Code Here

              }
            };
          }
         
        });
            this.stream = new BufferedOutputStream(new FileOutputStream(f));
          }
          if (buffer.length == 0) {
            stream.close();
            stream = null;
            streamIndex++;
View Full Code Here

        ClobType cv = new ClobType(clob);
        String key = cv.getReferenceStreamId();
       
        // now force to serialize
        File saved = new File(UnitTestUtil.getTestScratchPath()+"/clobassaved.bin"); //$NON-NLS-1$
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(saved));
        out.writeObject(cv);
        out.close();
       
        // now read back the object from serilized state
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(saved));
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.