upfile.java
来自「这是一个网上书站的例子」· Java 代码 · 共 40 行
JAVA
40 行
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 + =
减小字号Ctrl + -
显示快捷键?