急问一问题 FileInputStream方法,老是提示找不到指定文件! 试试FileInputStream("./new.txt"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FileInputStream(context.getRealPath("/yourdir/new.txt")) 还是找不到啊JSP文件 C:\Tomcat\webapps\ROOT\newtest.jspnew.txt文件 C:\Tomcat\webapps\ROOT\new.txt new.txt放到根目录FileInputStream("/new.txt"); public void addClob() { try { //取得旧表得ID列表 // ResultSet rsTmp=DoSQL.Select("zd2_T_NEWS2","COL007",false); //String [] idList = SQLAI.getPrimaryKey("fj_xt_zd2_T_news"); String[] idList = this.getContent(); String titleList[] = this.getTitle(); String newsID [] = this.getNewsID(); //--开始读取大文本到数据库-- int countReplain = 0; //统计导入的大文件个数 for (int i = 0; i < idList.length; i++) { //--初始化数据库连接-- java.sql.Connection con = Dbconn.pubGetCon(); con.setAutoCommit(false); java.sql.Statement st = con.createStatement(); PreparedStatement psSel = null; PreparedStatement ps = null; ResultSet rs = null; //构造文件名 String path = "c:\\abc\\" + idList[i].trim() + ".txt"; //--取得数据库重中的大文本字段-- int id = i; rs = null; /* 查询此CLOB对象并锁定 */ String sql = "insert into t_news_message2 (id,title,content) values (?,?,empty_clob())"; String selectSql = "SELECT content FROM t_news_message2 WHERE ID=" + id + " FOR UPDATE"; String sqlUpdate = "update " + "t_news_message" + " SET content=? where id = " + id; psSel = con.prepareStatement(sql); psSel.setInt(1, id); psSel.setString(2, titleList[i]); psSel.executeUpdate(); rs = st.executeQuery(selectSql); rs.next(); CLOB clob = (CLOB) rs.getClob("content"); //---- BufferedReader in = null; //BufferedWriter out=null; try { //-- 向CLOB对象中写入数据 -- //out = new BufferedWriter(clob.getCharacterOutputStream()); in = new BufferedReader(new FileReader(path)); if (in != null) { String s; String sAll = new String(""); if(this.getCountNewsID(newsID[i])>0) { sAll = sAll + this.getPicUrl(newsID[i]) ; } while ((s = in.readLine()) != null) { sAll = sAll + " "+ s + "<br>"; } System.out.println(sAll); clob.putString(1L, sAll); ps = con.prepareStatement(sqlUpdate); ps.setClob(1, clob); ps.executeUpdate(); // int writeClob; // while ( (writeClob = in.read()) != -1) { // out.write(writeClob); // } countReplain++; //统计目前已经导入的大文本个数 con.commit(); con.setAutoCommit(true); } } catch (Exception e1) { System.out.println("Lose file:" + path); if (in != null) in.close(); //if(out!=null)out.close(); //---- } if (rs != null) rs.close(); if (st != null) st.close(); if (ps != null) ps.close(); if (psSel != null) psSel.close(); if (con != null) con.close(); //---- } System.out.println("共有文件" + countReplain); } catch (Exception e) { } } String path = "c:\\abc\\" + idList[i].trim() + ".txt"; 怎么重置xml中的文本内容,并且当其中包括%1$s格式时 struts2 session中的数据的问题,在线等 如何用properties中的替换jsp页面中的value??? 如何使JSP同时提交到2个表单中,而只显示第2个表单中的文字,使得用户感觉不到还同时提交到了另一个表单中? 关于例外啊!还有怎么自己定义例外呢!分不够再给啊!期望得到高手的精髓理解阿 大家帮忙啊!!!!急!!!!! 关于子页面向父页面传值的问题: 空指针异常的问题 怎样用Servlet显示一个动态”树“? jsp服务器配置? 我的程序为什么找不到 javax.servlet.jsp.*
FileInputStream("/new.txt");
try {
//取得旧表得ID列表
// ResultSet rsTmp=DoSQL.Select("zd2_T_NEWS2","COL007",false);
//String [] idList = SQLAI.getPrimaryKey("fj_xt_zd2_T_news");
String[] idList = this.getContent();
String titleList[] = this.getTitle();
String newsID [] = this.getNewsID();
//--开始读取大文本到数据库--
int countReplain = 0; //统计导入的大文件个数 for (int i = 0; i < idList.length; i++) {
//--初始化数据库连接--
java.sql.Connection con = Dbconn.pubGetCon();
con.setAutoCommit(false);
java.sql.Statement st = con.createStatement();
PreparedStatement psSel = null;
PreparedStatement ps = null;
ResultSet rs = null; //构造文件名
String path = "c:\\abc\\" + idList[i].trim() + ".txt";
//--取得数据库重中的大文本字段--
int id = i;
rs = null;
/* 查询此CLOB对象并锁定 */
String sql =
"insert into t_news_message2 (id,title,content) values (?,?,empty_clob())";
String selectSql =
"SELECT content FROM t_news_message2 WHERE ID="
+ id
+ " FOR UPDATE";
String sqlUpdate =
"update "
+ "t_news_message"
+ " SET content=? where id = "
+ id;
psSel = con.prepareStatement(sql);
psSel.setInt(1, id);
psSel.setString(2, titleList[i]);
psSel.executeUpdate();
rs = st.executeQuery(selectSql);
rs.next();
CLOB clob = (CLOB) rs.getClob("content");
//----
BufferedReader in = null;
//BufferedWriter out=null;
try {
//-- 向CLOB对象中写入数据 --
//out = new BufferedWriter(clob.getCharacterOutputStream());
in = new BufferedReader(new FileReader(path));
if (in != null) {
String s;
String sAll = new String("");
if(this.getCountNewsID(newsID[i])>0)
{
sAll = sAll + this.getPicUrl(newsID[i]) ;
}
while ((s = in.readLine()) != null) { sAll = sAll + " "+ s + "<br>";
}
System.out.println(sAll); clob.putString(1L, sAll);
ps = con.prepareStatement(sqlUpdate);
ps.setClob(1, clob);
ps.executeUpdate();
// int writeClob;
// while ( (writeClob = in.read()) != -1) {
// out.write(writeClob);
// }
countReplain++; //统计目前已经导入的大文本个数
con.commit();
con.setAutoCommit(true);
}
} catch (Exception e1) {
System.out.println("Lose file:" + path);
if (in != null)
in.close(); //if(out!=null)out.close(); //----
} if (rs != null)
rs.close();
if (st != null)
st.close();
if (ps != null)
ps.close();
if (psSel != null)
psSel.close();
if (con != null)
con.close();
//----
} System.out.println("共有文件" + countReplain);
} catch (Exception e) {
} }