这段代码是什么意思

zhoubo42088 2012-08-21 09:22:15
private MediaFilePath dayOverFilePath;
private String suffixStr = ".dat";
private String prefixStr = "";
private final Logger logger = Logger.getLogger(this.getClass());

@Override
public List<String> getFilePathListByDateFilter(String merchtNo,
String startDate, String endDate,String status) throws BusinessException {
if(status.equals("zf")){
prefixStr="";
}else{
prefixStr="REF";
}
List<Object> listo = new ArrayList<Object>();
List<String> list = new ArrayList<String>();
String filePath = dayOverFilePath.getFilePath() + merchtNo;
logger.debug("文件路径地址"+filePath);
String datestr = startDate.substring(0, startDate.length() - 2);

try {
File file = new File(filePath);
FileFilter filter = new PrefixFileFilter(prefixStr+merchtNo + datestr);

File[] files = file.listFiles(filter);

if(files != null ){
for (File tem : files) {
String fileName = tem.getName();
String subStr = fileName.substring((prefixStr+merchtNo).length(), fileName
.indexOf(suffixStr));

if (Long.parseLong(subStr) >= Long.parseLong(startDate)
&& Long.parseLong(subStr) <= Long.parseLong(endDate)) {

AccontCheck ac=new AccontCheck();
ac.setMerchtNo(merchtNo);
ac.setName(tem.getName());
ac.setDate(Long.parseLong(subStr));
listo.add(ac);
// list.add("/" + merchtNo + "/" + tem.getName());
}

}
//排序
ListSort listSort =new ListSort();
Collections.sort(listo,listSort);
for (int i = 0; i < listo.size(); i++) {
AccontCheck ac=(AccontCheck)listo.get(i);
list.add("/"+ac.getMerchtNo()+"/"+ac.getName());
}
} else {
logger.error("无此【"+merchtNo+"】的对账文件保存目录");
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("搜索文件错误!");
}

return list;
}
...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhoubo42088 2012-08-23
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

你的意思是把inputStream后的按照行对行 列对列规则写入到XLS中?
[/Quote]

是的

public void downLoadFile(HttpServletRequest request,
HttpServletResponse response) throws Exception {

String date = request.getParameter("date");
String status=request.getParameter("status");
String merchtNo = userDetailsUtils.getMerchantNoByContext();
if (StringUtils.isBlank(date)) {
// 无效请求,返回至首页
response.sendRedirect(request.getContextPath()+"/index.htm");
return;
}

try {
// 打开指定文件的流信息
InputStream inputStream = accountCheckFormManager.getFileByDate(
merchtNo, date);
// 写出流信息
//inputStream.getClass().
System.out.println(inputStream.read());
int data = -1;

OutputStream outputstream = response.getOutputStream();

// 清空输出流
response.reset();
// 设置响应头和下载保存的文件名
response.setHeader("content-disposition", "attachment;filename="+(status.equals("tk")?"REF":"")+ merchtNo + date + ".xls");
// 定义输出类型
response.setContentType("APPLICATION/txt");

while ((data = inputStream.read()) != -1) {
outputstream.write(data);
}
inputStream.close();
outputstream.close();
} catch (Exception e) {
String errorMsg = e.getMessage();
response.setContentType("text/html; charset=UTF-8");
response.getWriter().write(
"<script>alert('" + errorMsg + "')</script>");
} finally {
response.flushBuffer();
}
}
}

这是原先的 出来时无序的 现在希望排序正确
以学习为目的 2012-08-21
  • 打赏
  • 举报
回复
你的意思是把inputStream后的按照行对行 列对列规则写入到XLS中?
zhoubo42088 2012-08-21
  • 打赏
  • 举报
回复
好了上面的问题我懂了 但是现在头有一个
InputStream inputStream = accountCheckFormManager.getFileByDate(MerchtNo, date);
inputStream 这个里面的格式是规范的 行对行 列对列
我怎么把他规则的写入到XLS中

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧