uploadfilewriter.java

来自「基于JAVA的学生就业信息网 实现对信息浏览 检索 审核 修改和删除」· Java 代码 · 共 47 行

JAVA
47
字号
/*
 * Created on 2005-6-16
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.ug.sztz.domain.upload;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @author xix
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class UploadFileWriter {
	private InputStream in;
	private String      outPath;
	/**
	 * 
	 */
	public UploadFileWriter() {
		// TODO Auto-generated constructor stub
	}
	
	public UploadFileWriter(InputStream in, String outPath){
		this.in = in;
		this.outPath = outPath;
		
	}
	
	public void save()  throws Exception{
	    OutputStream bos = new FileOutputStream(outPath);
	    int bytesRead = 0;
        byte[] buffer = new byte[8192];
        while ((bytesRead = in.read(buffer, 0, 8192)) != -1) {
            bos.write(buffer, 0, bytesRead);
        }
        bos.close();
	}
	
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?