çä¾å
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"); //æä»¶æº :æ¾ç±»æ件ä¸çè¿ä¸ª.jpgæ件
FileCopyUtils.copy(resource.getInputStream(),os);
PS:(
//FileOutputStream os=new FileOutputStream(new File(fpt+".jpg"));
//FileSystemResource resource = new FileSystemResource( "E:/union.jpg");
//FileCopyUtils.copy(resource.getInputStream(),os);
FileStstemResource //æ ¹æ®æ件路å¾æ¾
)
System.out.print("SUCEESS");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//**************************************************************************************************************
//*****************************************************å
容补å
éè¿Spring Resourceæ¥å£è·åèµæº
温馨提示:答案为网友推荐,仅供参考