📄 uploadfileutil.java
字号:
package com.szmx.tlms.util;
import org.apache.struts.upload.FormFile;
import java.io.*;
/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2006-8-23
* Time: 12:14:47
* To change this template use File | Settings | File Templates.
*/
public class UploadFileUtil {
public boolean upFile(FormFile file, String upFilePath) {
try {
InputStream stream = file.getInputStream();//把文件读入
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream bos = new FileOutputStream(upFilePath + "/" +
file.getFileName());//建立一个上传文件的输出流
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);//将文件写入服务器
}
bos.close();
stream.close();
} catch (Exception e) {
System.err.print(e);
return false;
}
return true;
}
public void createFolder(String folderPath) {
File thePath = new File(folderPath);
if (thePath.isDirectory() == false)//如果该目录不存在,则生成新目录
{
thePath.mkdirs();
}
}
public void openFile(String filePath) {
try {
Runtime r = Runtime.getRuntime();
r.exec("cmd /c start " + filePath);
} catch (Exception e) {
System.err.print(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -