阅读背景:

指维科技P2P网贷平台的上传图片功能代码分享

来源:互联网 

private File file; 
private String fileFileName; 
private String picture; 
InputStream is = new FileInputStream(file); 
//引入一个IO流的输入流
String root = ServletActionContext.getRequest() 
.getRealPath("/bookpicture"); 
//通过REQUEST来得到相对地址,并在后面加上/bookpicture
File f = new File(root, this.getFileFileName()); 
//定义一个FILE文件,第一个参数是文件的路径,第二个是文件的名字

picture="."+"\"+"bookpicture"+"\"+this.getFileFileName();
//为PICTURE字符串赋值,/地址/文件名 
System.out.println 
("======picture====="+picture); 
//从掌握台输出Picture

OutputStream os = new FileOutputStream(f); 
//第一个文件的输出流
byte[] buffer = new byte[1024];
//定义一个bufer的字符串,长度为1024
 
int len = 0; 
while ((len = is.read(buffer)) > 0) { 
//如果从制订文件中读取到的信息为停止就持续重复
os.write(buffer, 0, len); 
//将文件读出的内容写入到指定的文件中

}private File file; 
private String fileFileName;




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: