package com.controller;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.util.FileCopyUtils;
/**
*
* @function 利用spring中的FileCopyUtils.copy()复制文件
* @author liudd
* @time Apr 18, 2013
* @since restIframe
*/
public class FileutilsTest {
public static void main(String[] args) {
try {
FileOutputStream os=new FileOutputStream(new File("d:/22.jpg"));
Resource resource=new ClassPathResource("/1.jpg");
FileCopyUtils.copy(resource.getInputStream(),os);
System.out.print("SUCEESS");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.util.FileCopyUtils;
/**
*
* @function 利用spring中的FileCopyUtils.copy()复制文件
* @author liudd
* @time Apr 18, 2013
* @since restIframe
*/
public class FileutilsTest {
public static void main(String[] args) {
try {
FileOutputStream os=new FileOutputStream(new File("d:/22.jpg"));
Resource resource=new ClassPathResource("/1.jpg");
FileCopyUtils.copy(resource.getInputStream(),os);
System.out.print("SUCEESS");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}