http://www.csdn.net/expert/topic/797/797602.xml?temp=.9226648
解决方案 »
- eclipse的VE 插件如何安装
- 帮我看一下是什么错误!
- [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.的错误消息
- 请问怎么把网络上一个文件(http://www.test.com/abc.xml)拷贝到本机的一个目录里呢?有例子么?多谢!
- 为什么页面没有显示,急
- [求助]为什么有异常?
- 线程相关,JEditorPane相关
- 今天买了 Java How To Programme 这本书,大家说这本书怎么样
- 有关字符串的2个小问题?
- 不明白的错误!!!
- 关于java读取excel
- 如何将获取的格林威治时间转换为本地时区的时间?急……
public void CSVOUT(ClientRowSet rsQuery)
{
try
{
BufferedWriter bufout;
File FilePath = new File(strCSVOUT_PATH+"\\"+
this.getSessionParam().getValueAsString(CMN_APP_ColConstant.MANNO)
+"_nof.csv");
bufout = new BufferedWriter(new FileWriter(FilePath));
bufout.write(",休暇届出設定,,");
bufout.newLine();
bufout.write("届出コード,届出内容,対象MHシート,日数");
String outRow ="";
rsQuery.moveFirst();
for (int i=0;i<rsQuery.getRowCount();i++)
{
outRow = rsQuery.getValueAsString(CMN_APP_ColConstant.NOTIF_CD);
outRow += ",";
outRow += rsQuery.getValueAsString(CMN_APP_ColConstant.NOTIF_NAME);
outRow += ",";
outRow += rsQuery.getValueAsString(CMN_APP_ColConstant.MHSHEET);
outRow += ",";
outRow += rsQuery.getValueAsString(CMN_APP_ColConstant.ABS_DAY);
rsQuery.moveNext();
bufout.newLine();
bufout.write(outRow);
}
bufout.close(); }
catch (Exception e)
{
System.out.println(e);
}
}
读取:
public void CSVIN(java.util.Vector requestParamNames,
java.util.Hashtable requestParamValues)
{
try
{
UploadFileData updfile = (UploadFileData)requestParamValues.get("UPLOAD");
BufferedReader in = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(updfile.getContent()),"Cp943C"));
String inStr = null;
BufferedWriter bufout;
File FilePath = new File(strCSVIN_PATH+"\\"+
this.getSessionParam().getValueAsString(CMN_APP_ColConstant.MANNO)
+"_nof.csv");
bufout = new BufferedWriter(new FileWriter(FilePath)); int EleNo = 1;
int PointPos = 0;
String RowEle = "";
String RowAll = "";
CsvIn = "";
rsCsvin.getParamSet().removeAllParams();
while ((inStr = in.readLine()) != null)
{
if (rowNo!=1)
{
bufout.newLine();
}
bufout.write(inStr);
//<--------------------------------->
if (rowNo==3)
{
CsvIn = CsvIn + inStr;
}
else if (rowNo>3)
{
CsvIn = CsvIn + "/n" + inStr;
}
//<--------------------------------->
rowNo++;
}
bufout.close();
in.close();
rsRowNo = 0; }
catch(Exception x)
{
x.printStackTrace();
}
}
需要说明一下:
这里的方法一般在JAVA里是可用的,但是我这些程序是用框架做的,所以呢?如果有什么问题,你只要修改一下就OK了!
祝你好运...........