ftp类:client.listFiles(路径)、
FtpConfig config = new FtpConfig();
config.setHost(address);
config.setPort(port);
config.setUsername(username);
config.setPassword(password);
config.setFtpFileDir(FtpPath);
String br = new BufferedReader(new InputStreamReader(client.retrieveFileStream(filePath), "UTF-8"));
String str = null;
while ((str = br.readLine()) != null) {
//str处理
}
上传下载类:
spring-servlet.xml
<!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 指定所上传文件的总大小不能超过200KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 -->
<property name="maxUploadSize" value="2000000000"/>
<property name="defaultEncoding" value="UTF-8"></property>
</bean>
@RequestMapping(value = "/upLoad")
public String upload(HttpSession session, HttpServletRequest request, HttpServletResponse response,@RequestParam MultipartFile upLoad) throws IOException {}
@RequestMapping(value = "/download")
public String downLoad(HttpServletResponse response, String filePath, String fileName) {根据文件名、路径等下载文件}
上传
$("#from").attr('action', '${ctx}/show/upLoad.action');
$("#from").submit();
下载
xml解析类:
http://blog.sina.com.cn/s/blog_03c54d1001012srj.html
时间类:
Calendar cal = Calendar.getInstance();
if (cal.get(Calendar.HOUR_OF_DAY) < 4 || cal.get(Calendar.HOUR_OF_DAY) >= 8) {
LOGGER.info("当前时间: {}, 不在4-8点范围内,不执行批处理任务.",
new Object[] {DatetimeUtil.formatDatetime(new Date())});
}
execl处理类:
inputStream = MultipartFile.getInputStream();
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
// 跳过表头
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
Row row = sheet.getRow(i);
}