- 浏览: 242990 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
无它唯勤:
...
Spring Ioc AOP -
dubaopeng:
挺好的,拿去改改!
java 解析csv文件 -
灵程大哥:
先试一下,看行不行
java 判断文本文件编码 -
pxjianke:
谢谢兄弟。我现在在测试插入千万级数据。做测试。这个太有用了。
Oracle 高速批量速插入数据 解决方案
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
-->package com.roadway.edmail.fboperate;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.roadway.edmail.fboperate.model.OperateModel;
import com.roadway.edmail.util.StrUtil;
import com.roadway.edmail.util.SysParameters;
public class OperateModelCacheHelper
{
/** 日志记录 */
private static Logger logger = Logger
.getLogger(OperateModelCacheHelper.class.getName());
/** 未处理的操作模型的文件的路径 */
private static String operatedModelPath = SysParameters.basicPath
+ "operatingModel.txt";;
/** 已经处理的操作模型的文件的路径 */
private static String operatingModelPath = SysParameters.basicPath
+ "operatedModel.txt";
/**
* 本方法用于把一个操作模型存入到临时文件
*
* @param filePath
* 文件的路径
* @param model
* 对像模型
*/
public static synchronized void model2File(String filePath,
OperateModel model, boolean isAppend)
{
/** 如果对象为NULL */
if (model == null)
{
return;
}
File operatingFile = new File(filePath);
/** 如果文件不存在,退出程序 */
if (!operatingFile.exists())
{
return;
}
FileOutputStream fos = null;
try
{
fos = new FileOutputStream(operatingFile, isAppend);
fos.write(model.toString().getBytes());
}
catch (Exception ex)
{
/** 把异常信息加入到日志 */
OperateModelCacheHelper.logger.error(StrUtil.getExceptionInfo(ex,
"edm_h"));
}
finally
{
try
{
/** 关闭输入输出流 */
fos.close();
}
catch (Exception e)
{
}
}
}
/**
* @param filePath
* @return
*/
public static synchronized List<OperateModel> file2Models(String filePath)
{
/** 装models的集合 */
List<OperateModel> models = new ArrayList<OperateModel>();
File operatingFile = new File(filePath);
/** 如果文件不存在,退出程序 */
if (!operatingFile.exists())
{
return models;
}
StringBuffer content = new StringBuffer();
FileInputStream fis = null;
try
{
fis = new FileInputStream(operatingFile);
byte[] buffer = new byte[1024];
int byteRead = 0;
while ((byteRead = fis.read(buffer, 0, buffer.length)) != -1)
{
content.append(new String(buffer, 0, byteRead));
}
}
catch (Exception ex)
{
/** 把异常信息加入到日志 */
OperateModelCacheHelper.logger.error(StrUtil.getExceptionInfo(ex,
"edm_h"));
}
finally
{
try
{
fis.close();
}
catch (Exception ex)
{}
}
String contentStr = content.toString();
/** 记录日志 */
OperateModelCacheHelper.logger.debug("file2Model的内容为:" + contentStr);
String[] strModels = contentStr.split("\n\r");
OperateModel model = null;
for (int len = 0; len < strModels.length; len++)
{
String[] infos = strModels[len].split("[,]");
if (infos.length == 3)
{
model = new OperateModel(infos[0], infos[1], infos[3]);
models.add(model);
}
}
return models;
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.roadway.edmail.fboperate.model.OperateModel;
import com.roadway.edmail.util.StrUtil;
import com.roadway.edmail.util.SysParameters;
public class OperateModelCacheHelper
{
/** 日志记录 */
private static Logger logger = Logger
.getLogger(OperateModelCacheHelper.class.getName());
/** 未处理的操作模型的文件的路径 */
private static String operatedModelPath = SysParameters.basicPath
+ "operatingModel.txt";;
/** 已经处理的操作模型的文件的路径 */
private static String operatingModelPath = SysParameters.basicPath
+ "operatedModel.txt";
/**
* 本方法用于把一个操作模型存入到临时文件
*
* @param filePath
* 文件的路径
* @param model
* 对像模型
*/
public static synchronized void model2File(String filePath,
OperateModel model, boolean isAppend)
{
/** 如果对象为NULL */
if (model == null)
{
return;
}
File operatingFile = new File(filePath);
/** 如果文件不存在,退出程序 */
if (!operatingFile.exists())
{
return;
}
FileOutputStream fos = null;
try
{
fos = new FileOutputStream(operatingFile, isAppend);
fos.write(model.toString().getBytes());
}
catch (Exception ex)
{
/** 把异常信息加入到日志 */
OperateModelCacheHelper.logger.error(StrUtil.getExceptionInfo(ex,
"edm_h"));
}
finally
{
try
{
/** 关闭输入输出流 */
fos.close();
}
catch (Exception e)
{
}
}
}
/**
* @param filePath
* @return
*/
public static synchronized List<OperateModel> file2Models(String filePath)
{
/** 装models的集合 */
List<OperateModel> models = new ArrayList<OperateModel>();
File operatingFile = new File(filePath);
/** 如果文件不存在,退出程序 */
if (!operatingFile.exists())
{
return models;
}
StringBuffer content = new StringBuffer();
FileInputStream fis = null;
try
{
fis = new FileInputStream(operatingFile);
byte[] buffer = new byte[1024];
int byteRead = 0;
while ((byteRead = fis.read(buffer, 0, buffer.length)) != -1)
{
content.append(new String(buffer, 0, byteRead));
}
}
catch (Exception ex)
{
/** 把异常信息加入到日志 */
OperateModelCacheHelper.logger.error(StrUtil.getExceptionInfo(ex,
"edm_h"));
}
finally
{
try
{
fis.close();
}
catch (Exception ex)
{}
}
String contentStr = content.toString();
/** 记录日志 */
OperateModelCacheHelper.logger.debug("file2Model的内容为:" + contentStr);
String[] strModels = contentStr.split("\n\r");
OperateModel model = null;
for (int len = 0; len < strModels.length; len++)
{
String[] infos = strModels[len].split("[,]");
if (infos.length == 3)
{
model = new OperateModel(infos[0], infos[1], infos[3]);
models.add(model);
}
}
return models;
}
}
发表评论
-
一刻钟精通正则表达式(转)
2007-11-07 11:23 851想必很多人都对正则表达式都头疼。今天,我以我的 ... -
Map、ArrayList 的遍历
2007-11-08 12:50 780public static void main(String[ ... -
Hibernate 连接池
2007-11-16 16:50 692<session-factory> < ... -
Hibernate检索对象的方式
2007-11-23 11:23 574Hibernate检索对象的方式 ... -
再温java jkd 环境变量设置
2007-12-04 15:16 848JAVA_HOME: C:\Program Files ... -
JAVA之路(转)
2007-12-04 18:12 605很多网友问我学习Java有 ... -
JMail
2007-12-05 10:42 839一.创建html格式的邮件 ... -
JAVA 检测网络是否为连通状态 ping
2007-12-07 19:27 2442要用java检测网络资源是否可用,我们可以采用以下两种方法: ... -
JMail 异常: java.lang.NoClassDefFoundError: javax/activation/DataSource
2007-12-11 16:56 2741今天开发邮件系统,发送程序能在main函数中顺利运行. ... -
JAVA 常用正则表达试
2007-12-11 21:21 771"^\d+$" //非负整数(正整数 + ... -
Linux - Tomcat
2007-12-14 18:36 7241.使用ps -ax | grep tomcat可以查询出内存 ... -
有返回值 存储过程 的 调用
2007-12-18 20:03 693有返回值的存储过程的调用方法如下: public class ... -
ECLIPS 经典 快键
2007-12-21 11:42 737Ctrl+1 快速修复(最经典的快捷键,就不用多说了) ... -
eclips 恢复 误删文件
2007-12-23 13:25 735今天,把我差点气死了,一不小心误删了很多重要文件. 后来才到网 ... -
JSP 统计在线人数
2007-12-24 10:39 709package com.test;import javax. ... -
The Software Engineer
2007-12-24 13:40 564http://siyn.iteye.com/ http://w ... -
Summarization of web project
2007-12-27 09:37 618开始一个web项目前应该注意一些什么?就自己的开发 ... -
正则表达式--2
2008-01-02 16:19 594正则表达式用于字符串处理,表单验证等场合,实用高效,但用到时总 ... -
java 正则表达式 长期总结
2008-01-03 18:46 685匹配文件后缀名:Pattern.matches("^ ... -
Test
2008-01-07 16:08 737package com.ed.cnc.servletListe ...
相关推荐
六年级英语下笔试题复习题精选.doc
人教版语文一年级下笔顺组词造句练习.doc
高中历史解题技巧再也不用对着历史试卷无处下笔素材
(中小学教育)三下笔算乘法(连除问题).ppt
(中小学教育)三下笔算乘法(连乘问题).ppt
物理服务器采购须知(不定期更新) 采购物理服务器时如果不清楚怎么下笔,可以参考该文件。
物理服务器采购须知(不定期更新) 采购物理服务器时如果不清楚怎么下笔,可以参考该文件。
适用于将要考CSP-S和CSP-J想要提升自己的小伙伴们:: 祝大家考的都会,蒙的都对~~~~ 考前满信心,下笔如有神;休息多静心,养好精气神;思考必细心,身心都入神;答题要用心,聚精又会神,高考心态最重要,千叮万嘱为...
对网络趋势有一定的了解,身边朋友在谈论什么,网友们在谈论什么,你都要清楚。甚至需要你来预判什么东西会火,提前准备,抢占先机。 2、整合 做一名新媒体工作人员,整合资料能力一定要强。网上相关的资料那么多,...
在解答之前,除了要弄清楚问题,还有必要弄清楚命题人的意图,从而能够针对问题从容做答。 2先分析,后下笔。明白了问题是什么以后,先把问题在脑海里过一遍,考虑好如何做答后,再依思路从容做答。而不要手忙脚乱、...
三年级数学下册4两位数乘两位数2笔算乘法3解决问题二作业课件新人教版
在手机pcb Layout中要注意哪些问题,还有显示部分需要布线么?
#资源达人分享计划#
学习使用ABP框架也有一段时间了,一直想全面了解下这个框架的整个来龙去脉,并把想把它使用历程整理成一个系列出来,不过一直没有下笔来写这篇文章的开篇,就是希望能够
为人师者慎下笔“,故此,本专栏亲自研究,实践,将调试过程中所遭所遇进行详细讲解,注意事项进行一一列举,希望能够帮助到各位初学OpenCV的小伙伴,避免走弯路,费时费力。 需opencv官网下载OpenCV-android-sdk将...
为人师者慎下笔“,故此,本专栏亲自研究,实践,将调试过程中所遭所遇进行详细讲解,注意事项进行一一列举,希望能够帮助到各位初学OpenCV的小伙伴,避免走弯路,费时费力。 需opencv官网下载OpenCV-android-sdk将...
为人师者慎下笔“,故此,本专栏亲自研究,实践,将调试过程中所遭所遇进行详细讲解,注意事项进行一一列举,希望能够帮助到各位初学OpenCV的小伙伴,避免走弯路,费时费力。 需opencv官网下载OpenCV-android-sdk将...
为人师者慎下笔“,故此,本专栏亲自研究,实践,将调试过程中所遭所遇进行详细讲解,注意事项进行一一列举,希望能够帮助到各位初学OpenCV的小伙伴,避免走弯路,费时费力。 需opencv官网下载OpenCV-android-sdk将...
为人师者慎下笔“,故此,本专栏亲自研究,实践,将调试过程中所遭所遇进行详细讲解,注意事项进行一一列举,希望能够帮助到各位初学OpenCV的小伙伴,避免走弯路,费时费力。 需opencv官网下载OpenCV-android-sdk将...
为人师者慎下笔“,故此,本专栏亲自研究,实践,将调试过程中所遭所遇进行详细讲解,注意事项进行一一列举,希望能够帮助到各位初学OpenCV的小伙伴,避免走弯路,费时费力。 需opencv官网下载OpenCV-android-sdk将...