jsp读数据库记录写入文件如何换行,就差最后一步了
<%
String rq[]=request.getParameterValues( "rq ");
String dwdm[]=request.getParameterValues( "dwdm ");
String xmdm[]=request.getParameterValues( "xmdm ");
String zhzh[]=request.getParameterValues( "zhzh ");
String zy[]=request.getParameterValues( "zy ");
String yspdh[]=request.getParameterValues( "yspdh ");
String je[]=request.getParameterValues( "je ");
String wdh[]=request.getParameterValues( "wdh ");
String fkdwmc[]=request.getParameterValues( "fkdwmc ");
String jdbz[]=request.getParameterValues( "jdbz ");
try{
File f=new File( "C:/Tomcat 5.0/webapps/ROOT ", "czzfff.txt ");
FileOutputStream o=new FileOutputStream(f,true);
DataOutputStream DataOut=new DataOutputStream(o);
for(int k=0;k <rq.length;k++)
{
DataOut.writeBytes(rq[k]);
DataOut.writeBytes(dwdm[k]);
DataOut.writeBytes(xmdm[k]);
DataOut.writeBytes(zhzh[k]);
DataOut.writeBytes(zy[k]);
DataOut.writeBytes(yspdh[k]);
DataOut.writeBytes(je[k]);
DataOut.writeBytes(wdh[k]);
DataOut.writeBytes(fkdwmc[k]);
DataOut.writeBytes(jdbz[k]);
}
DataOut.close();
o.close();
}
catch(
IOException e)
{}
catch(
NullPointerException ee)
{}
%>
写入文件成功
------解决方案--------------------mark
------解决方案-------------------- DataOut.writeBytes( "\r\n ");
------解决方案--------------------replace( '\r\n ', "\n ");
------解决方案--------------------for(int k=0;k <rq.length;k++)
老哥你rq.length在做什么
------解决方案--------------------要换行的地方输出一个换行符
------解决方案--------------------DataOut.writeBytes(jdbz[k]+ "\r\n ");试一下