Package java.io

Examples of java.io.FileOutputStream


 
  File fos = createNewResultsFile(queryID, querySetID,
    getGenerateDir());
 
 
  FileOutputStream actualOut = null;
  try {
      actualOut = new FileOutputStream(fos);
      PrintStream filePrintStream = new PrintStream(actualOut);
      if (ex != null) {
    TestResultSetUtil.printThrowable(ex, query, filePrintStream);
      } else if (result != null ){
    result.beforeFirst();
    TestResultSetUtil.printResultSet(result, query, MAX_COL_WIDTH, true, filePrintStream);
      }

  } catch (Exception e) {
      e.printStackTrace();
      throw new QueryTestFailedException(e);
  } finally {
      if (actualOut != null) {
    try {
        actualOut.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
      }
View Full Code Here


      File errorFile = new File(getOutputDir(), errorFileName);
     
      // the resultset will be passed in as null when
      // the error was due to a thrown exception, and not based comparison issues
      if (resultSet == null) {
    FileOutputStream actualOut = null;
    try {
        actualOut = new FileOutputStream(errorFile);
        PrintStream filePrintStream = new PrintStream(actualOut);
       

        TestResultSetUtil.printThrowable(queryError, sql, filePrintStream);
       
        filePrintStream.flush();

    } catch (Exception e) {
          e.printStackTrace();
          throw new QueryTestFailedException(e);
    } finally {
          if (actualOut != null) {
        try {
            actualOut.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
      }
View Full Code Here

    private void generateErrorResults(String querySetID, String queryID,
      String sql, File resultsFile, ResultSet actualResult,
      List<String> results)
      throws QueryTestFailedException {
 
  FileOutputStream actualOut = null;
  try {
      actualOut = new FileOutputStream(resultsFile);
      PrintStream filePrintStream = new PrintStream(actualOut);
     
      TestResultSetUtil.printResultSet(actualResult, sql, MAX_COL_WIDTH, true, filePrintStream);

//      if (results != null) {
//              for (Iterator<String> it=results.iterator(); it.hasNext();) {
//            String line = it.next();
//            filePrintStream.print(line);
//              }
//      } else {
//     
//    ResultSetUtil.printResultSet(actualResult, MAX_COL_WIDTH, true, filePrintStream);
//      }
           

  } catch (Exception e) {
      e.printStackTrace();
      throw new QueryTestFailedException(e);
  } finally {
      if (actualOut != null) {
    try {
        actualOut.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
      }
View Full Code Here

        Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, "Can't create propertyfile : " + labelFile.getLocation(), e));
      }      
    }

    // stores labelfile
    FileOutputStream labelFileStream = null;
    BufferedWriter writer = null;
    try {
      if (isSortLabelFiles()) {
        Properties labelProperties = loadLabel(labelFile);
        labelProperties.setProperty(key, value);
        SortedProperties sortedProperties = new SortedProperties();
        sortedProperties.putAll(labelProperties);
        labelFileStream = new FileOutputStream(labelFile.getLocation().toString());
        sortedProperties.store(labelFileStream, null);
     
       
      } else {
        // append new label to existing file
        Properties labelProperties = loadLabel(labelFile);
        if (!labelProperties.containsKey(key)) {
          writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(labelFile.getLocation().toFile(), true), "8859_1"));
          if(labelProperties.entrySet().size()>0){
            writer.newLine();
          }         
          writer.write(LabelFileEncodingHelper.saveConvert(key, true));
          writer.write("=");
          writer.write(LabelFileEncodingHelper.saveConvert(value, false));         
          writer.flush();
       
        }
      }
      labelFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
    } catch (FileNotFoundException e) {
      Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, "Can't find propertyfile : " + labelFile.getLocation(), e));
    } catch (IOException e) {
      Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, "Can't write propertyfile : " + labelFile.getLocation(), e));
    } catch (CoreException e) {
      Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, "Can't find propertyfile : " + labelFile.getLocation(), e));
    }finally{
      if(labelFileStream!=null){
        try {
          labelFileStream.close();
        } catch (IOException e) {       
        }
      }
      if(writer!=null){
        try {
View Full Code Here

            }
           
            int content_length = Integer.parseInt( cl_str );
           
            ByteArrayOutputStream  baos    = null;
            FileOutputStream    fos      = null;
         
            OutputStream  data_os;
           
            if ( content_length <= 256*1024 ){
             
              baos = new ByteArrayOutputStream();
           
              data_os  = baos;
             
            }else{
             
              post_file  = AETemporaryFileHandler.createTempFile();
             
              post_file.deleteOnExit();
             
              fos  = new FileOutputStream( post_file );
             
              data_os  = fos;
            }
           
            while( content_length > 0 ){
             
              int  len = is.read( buffer, 0, Math.min( content_length, buffer.length ));
             
              if ( len < 0 ){
               
                throw( new TRTrackerServerException( "premature end of input stream" ));
              }
             
              data_os.write( buffer, 0, len );
             
              content_length -= len;
            }
           
            if ( baos != null ){
             
              post_is = new ByteArrayInputStream(baos.toByteArray());
             
            }else{
             
              fos.close();
             
              post_is = new BufferedInputStream( new FileInputStream( post_file ), 256*1024 );
            }
           
            // System.out.println( "TRTrackerServerProcessorTCP: request data = " + baos.size());
View Full Code Here

    Map<Content, String> contentEntries = new HashMap<Content, String>();
    File furnitureLibraryFile = new File(furnitureLibraryName);
    File tmpFile = null;
    try {
      tmpFile = File.createTempFile("temp", ".sh3f");
      OutputStream out = new FileOutputStream(tmpFile);
      if (out != null) {
        // Create a zip output on file 
        zipOut = new ZipOutputStream(out);
        // Write furniture description file in first entry
        zipOut.putNextEntry(new ZipEntry(DefaultFurnitureCatalog.PLUGIN_FURNITURE_CATALOG_FAMILY + ".properties"));
View Full Code Here

      // Write content entries in a separate zipped file, if the file doesn't exist
      File file = new File(furnitureResourcesLocalDirectory, mainEntryDirectory + ".zip");
      if (file.exists()) {
        return;
      }
      zipOut = new ZipOutputStream(new FileOutputStream(file));
      mainEntryDirectory = "";
    } else {
      mainEntryDirectory += "/";
    }
   
View Full Code Here

   */
  private void copyContentToFile(InputStream in, File file) throws IOException {
    byte [] buffer = new byte [8192];
    OutputStream out = null;
    try {
      out = new FileOutputStream(file);
      int size;
      while ((size = in.read(buffer)) != -1) {
        out.write(buffer, 0, size);
      }
    } finally {
View Full Code Here

   * @throws FileNotFoundException
   * @see XMLEncoder
   */
  public void save( ) throws FileNotFoundException
  {
    OutputStream out = new FileOutputStream(fileName);
    doSave(out);
  }
View Full Code Here

   */
  public void saveAliases() {
    File aliasesFile = getAliasesFile();
    try {
      out.println("Saving aliases to: " + aliasesFile.getCanonicalPath());
      FileOutputStream fo = new FileOutputStream(aliasesFile);
      aliases.store(fo, "This aliases file was automatically written by Azureus");
    } catch (IOException e) {
      out.println("> Error saving aliases to " + aliasesFile.getPath() + ":" + e.getMessage());
    }
  }
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.