Friday, 15 June 2012

Program which copies input stream to file


Program which copies input stream to file use commons-io jar 2.3


package com.demo;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

public class FileInput {
public static void main(String[] args) throws FileNotFoundException {


File f1 = new File("c:\\Sunset.jpg");
FileInputStream fs = new FileInputStream(f1);
File destDir;
destDir = new File("d:/newfolder/file");
try {
FileUtils.copyInputStreamToFile(fs, destDir);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



}

}

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...