Package java.io

Examples of java.io.FileOutputStream



  public void writeFile(String fileName, byte[] data) throws UpdateException {
    File file = new File(mDir, fileName);
   
    FileOutputStream stream = null;
    try {
      stream = new FileOutputStream(file);
      stream.write(data);
     
      mBytesWritten += data.length;
    }
    catch (IOException exc) {
      // Try to delete the corrupt file
      if (stream != null) {
        try { stream.close(); } catch (IOException exc2) {}
      }
      file.delete();
     
      throw new UpdateException("Writing file failed: " + fileName, exc);
    }
    finally {
      if (stream != null) {
        try { stream.close(); } catch (IOException exc) {}
      }
    }
  }
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

            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

   *Update properties file.
   */
  public void saveProperties(String commentaires) {
    if (ok)
      try {
        FileOutputStream fos = new FileOutputStream(path);
        p.store(fos, commentaires);
      }
      catch (FileNotFoundException e) {
        e.printStackTrace();
      }
View Full Code Here

   *Update properties file.
   */
  public void saveProperties(String path, String commentaires) {
    if (ok)
      try {
        FileOutputStream fos = new FileOutputStream(path);
        p.store(fos, commentaires);
      }
      catch (FileNotFoundException e) {
        e.printStackTrace();
      }
View Full Code Here

      System.out.println("RAConfig.createFile : fileName = " + fileName);
    else if (verbose)
      System.out.println("create file \"" + fileName + "\"");

    new File(fileName).delete();
    FileOutputStream fos = new FileOutputStream(fileName);
    try {
      dump(is,fos);
    } finally {
      fos.close();
    }
  }
View Full Code Here

    else if (verbose)
      System.out.println("create file \"" + fileName + "\"");

    new File(fileName).delete();
    ByteArrayInputStream bis = new ByteArrayInputStream(input.getBytes());
    FileOutputStream fos = new FileOutputStream(fileName);
    try {
      dump(bis,fos);
    } finally {
      fos.close();
      bis.close();
    }
  }
View Full Code Here

      return false;

    new File(file2).delete();

    FileInputStream fis = new FileInputStream(file1);
    FileOutputStream fos = new FileOutputStream(file2);
    try {
      dump(fis,fos);
      return true;
    } finally {
      fos.close();
      fis.close();
    }
  }
View Full Code Here

        buff.append(line + "\n");
      }
    }
    file.delete();
    ByteArrayInputStream bis = new ByteArrayInputStream(buff.toString().getBytes());
    FileOutputStream fos = new FileOutputStream(file);
    try {
      dump(bis,fos);
    } finally {
      fos.close();
      bis.close();
    }
  }
View Full Code Here

        buff.append(line + "\n");
      }
    }
    file.delete();
    ByteArrayInputStream bis = new ByteArrayInputStream(buff.toString().getBytes());
    FileOutputStream fos = new FileOutputStream(file);
    try {
      dump(bis,fos);
    } finally {
      fos.close();
      bis.close();
    }
  }
View Full Code Here

TOP

Related Classes of java.io.FileOutputStream

Copyright © 2015 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.