技术标签: java文件上传工具类
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
public class UploadUtil {
public ServletFileUpload getFileUpload(String savePath) {
File file = new File(savePath);
if (!file.exists() && !file.isDirectory()) {
file.mkdir();
}
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
return upload;
}
public void uploadFile(List items, String savePath)
throws IOException {
for (FileItem item : items) {
if (!item.isFormField()) {
String filename = item.getName();
if (filename == null || "".equals(filename.trim())) {
continue;
}
filename = filename.substring(filename.lastIndexOf("\\") + 1);
InputStream in = item.getInputStream();
FileOutputStream out = new FileOutputStream(savePath + "\\"+ filename);
byte buffer[] = new byte[1024];
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
in.close();
out.close();
item.delete();
}
}
}
}```
调用JAVABEAN连接类
*&---------------------------------------------------------------------**& Report ZSDS5004*& T-Code: ZSD127*& Porgram Type: Program*& Description: 促销案导入*& DS Number: ERP-DS-SD-0113*&-----
【快速搞定】2分钟搞定极光推送(极光推送Android端集成)一、前言2分钟只是一个虚数哈,不过只要你速度快,两分钟还真是能搞定的哦。在2.1.8版本以前,极光的配置还是非常麻烦的,需要在清单文件(AndroidManifest.xml)里面各种配置,篇幅非常大。可能极光的开发者也意识到了这点,所以在2.1.8之后就加入了gradle的配置,简化了非常多的配置步骤。本文旨在通过简洁的步骤来快速完成极
(一)说在前面Python自带了GUI模块Tkinter,只是界面风格有些老旧。另外就是各种GUI框架了。之前安装过WxPython,并做了简单的界面。遂最近又重新搜索了一下网上关于Python GUI框架的问题,发现还是Qt呀。Python的Qt有PyQt和PySide吧。PyQt 是商业及 GPL 的版权, 而 PySide 是 LGPL。大意也就是PyQt开发商业软件是要购买授权的,而PyS...
开始学习充电啦,记录一下进度,希望每天都能进步... fighting! 都是书上的内容,总结。写下来只为加深记忆:第一条 熟悉 OCobject-C使用“消息结构”而非“函数调用”。区别:前者运行时执行的代码由运行环境决定;后者由编译器决定。* OC为C语言添加了面向对象特性,是其超集。OC使用动态绑定的消息结构,也就是说,在运行时才会检查对象类型。接收一条消息之后,究竟应执行何种代码,...
要说零复制,就要先说管道pipe。pipe在linux的实现中,用的是生产者消费者的模型,在linux/pipe_fs_i.h中我们能看到一下的代码:#define PIPE_DEF_BUFFERS 16//...struct pipe_inode_info { struct mutex mutex; wait_queue_head_t wait;
一、load事件<!DOCTYPE HTML><html> <head> <meta charset="utf-8"> <title>img - load event</title></head> <body> <img id="img1" src="http://pic1.win4000.com/wallpaper/f/51c3bb99a21ea.j.
1、Schaar#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Scharr算子是高斯平滑与微分操作的结合体,所以它具有很好的抗噪声能力。"""import cv2 as cvimport numpy as np'''添加椒盐噪声prob:噪声比例'''def sp_noise(image, prob): output = np.zeros(image.shape, np.uint8) thres = 1 -
物联网网关"""功能定义:为智能云设备提供云服务、用户通过手机远程控制智能设别运行项目依赖:Twisted + SQLAlchemy + ZeroMQOpenSSL : 安全组件库,提供安全的传输层接口 —— 完成对SSL接口的开发ZeroMQ :高效的消息队列中间件 —— 完成不同主机间的通信其他依赖库 : 查看 requirement.txt 文件"""# 安装其他依...
Why?James-3.1.0 较于 2.3 功能更加完善,详情参见官网: https://github.com/apache/james-project/#apache-james-project 拥抱Docker,可以将数据卷挂载到Host上,还可集成ElasticSearch或Lucene(基于Guice): https://github.com/apache/james-proj...
I'm writing a simple Java Application with Apache PDFBox.I have a several PDFs where the last page is the index of the content in the previous pages.I need the index (last page) became the first page ...
目录JVM由三部分组成1. 类加载子系统,可以根据指定的全限定名来载入类或接口。Java类加载机制_trigger333的博客-程序员宅基地_java类加载的机制2. 执行引擎,负责执行那些包含在被载入类的方法中的指令。3. 运行时数据区.JVM内存结构_trigger333的博客-程序员宅基地_jvm内存结构具体的JVM由三部分组成类加载子系统、执行引擎、运行时数据区。1. 类加载子系统,可以根据指定的全限定名来载入类或接口。Java类加载机制_tr...