Package cz.muni.fi.sindb2xhtml.utils

Source Code of cz.muni.fi.sindb2xhtml.utils.FileUtils

package cz.muni.fi.sindb2xhtml.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import cz.muni.fi.sindb2xhtml.Sindb2xhtmlException;

public class FileUtils {
  public static void copyfile(InputStream srcStream, String destFilePath) throws Sindb2xhtmlException{
    if (srcStream == null)
    {
      throw new IllegalArgumentException("InputStream is null.");
    }
    if (destFilePath == null)
    {
      throw new IllegalArgumentException("destFilePath is null.");
    }   
    try{

      File f2 = new File(destFilePath);
     
      OutputStream out = new FileOutputStream(f2);

      byte[] buf = new byte[1024];
      int len;
      while ((len = srcStream.read(buf)) > 0){
      out.write(buf, 0, len);
      }
      srcStream.close();
      out.close();

      }
      catch(FileNotFoundException e){
        throw new Sindb2xhtmlException(e);
      }
      catch(IOException e){
        throw new Sindb2xhtmlException(e);
      }
      }
}
TOP

Related Classes of cz.muni.fi.sindb2xhtml.utils.FileUtils

TOP
Copyright © 2018 www.massapi.com. 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.