⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upfile.java

📁 这是一个网上书站的例子
💻 JAVA
字号:
package com.upfile;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class UpFile {
	private String storepath;
	private InputStream is;
	private String newname;
	public UpFile(String storepath,InputStream is,String newname)
	{
		this.storepath=storepath;
		this.is=is;
		this.newname=newname;
	}
	public boolean upfileToserver()
	{
		
		try {
			OutputStream os = new FileOutputStream(storepath+newname);
			
			int bytes=0;
			byte[] buffer=new byte[8192];
			while((bytes=is.read(buffer, 0, 8192))!=-1)
			{
				os.write(buffer,0,bytes);
			}
			os.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
		
		return true;
	}

}

⌨️ 快捷键说明

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