資源簡介
一個簡單的web jsp投票系統(適合初學者) 一個簡單的web jsp投票系統(適合初學者) 一個簡單的web jsp投票系統(適合初學者)

代碼片段和文件信息
package?com.bu3g.test;
import?java.io.BufferedReader;
import?java.io.FileNotFoundException;
import?java.io.FileOutputStream;
import?java.io.FileReader;
import?java.io.IOException;
import?java.io.PrintWriter;
public?class?Counter?{
private?String?currentRecord?=?null;//文本變量
private?BufferedReader?file;//讀取文件數據的緩存流
private?String?path;//文件完整路徑名
//readFile方法用來讀取文件filePath中的數據并返回所需求的投票數的數組
public?int[]?readFile(String?filePath)?throws?FileNotFoundException?{
path?=?filePath;
file?=?new?BufferedReader(new?FileReader(path));//創建新的BufferedReader對象
int?returnStr[]=new?int[5];
try?{
currentRecord?=?file.readLine();//讀取一行數據并保存到currentRecord文本變量中
}?catch?(IOException?e)?{
System.out.println(“讀文件錯誤.“);
}
if?(currentRecord?!=?null)?{
String[]?str?=?currentRecord.split(“#“);
for?(int?i?=?0;?i? returnStr[i]?=?Integer.parseInt(str[i]);
}
return?returnStr;
}
//writeFile方法用來將數組counter寫入到文本文件filePath中
public?void?writeFile(String?filePath?int[]?counter)
throws?FileNotFoundException?{
path?=?filePath;
String?writeStr?=?““;
for?(int?i?=?0;?i? if?(i?!=?counter.length?-?1)
writeStr?+=?counter[i]?+?“#“;
else
writeStr?+=?counter[i];
}
try?{
//創建PrintWriter對象用于寫入數據到文件中
PrintWriter?pw?=?new?PrintWriter(new?FileOutputStream(filePath));
pw.println(writeStr);//用文本格式寫入writeStr
pw.close();//關閉流
}?catch?(IOException?e)?{
System.out.println(“寫文件錯誤“?+?e.getMessage());
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????340??2010-05-21?16:17??vote\.classpath
?????文件????????285??2010-05-31?20:53??vote\.myme
?????文件???????1222??2010-05-21?16:29??vote\.project
?????文件?????????11??2010-05-21?16:54??vote\WebRoot\count.txt
?????文件????????857??2010-05-21?17:03??vote\WebRoot\do_vote.jsp
?????文件???????3918??2010-05-21?16:59??vote\WebRoot\show.jsp
?????文件???????2350??2010-05-21?16:26??vote\WebRoot\vote.jsp
?????文件????????284??2010-05-21?16:17??vote\WebRoot\WEB-INF\web.xm
?????文件???????2143??2010-05-31?20:53??vote\WebRoot\WEB-INF\classes\com\bu3g\test\Counter.class
?????文件?????????39??2010-05-21?16:17??vote\WebRoot\me
?????文件????????843??2010-05-31?23:07??vote\WebRoot\images\1.gif
?????文件????????586??2010-05-21?16:18??vote\WebRoot\css\st
?????文件???????1675??2010-05-21?17:04??vote\src\com\bu3g\test\Counter.java
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\WEB-INF\classes\com\bu3g\test
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\WEB-INF\classes\com\bu3g
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\WEB-INF\classes\com
?????目錄??????????0??2010-08-26?16:24??vote\src\com\bu3g\test
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\WEB-INF\lib
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\WEB-INF\classes
?????目錄??????????0??2010-08-26?16:24??vote\src\com\bu3g
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\WEB-INF
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\me
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\images
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot\css
?????目錄??????????0??2010-08-26?16:24??vote\src\com
?????目錄??????????0??2010-08-26?16:24??vote\WebRoot
?????目錄??????????0??2010-08-26?16:24??vote\src
?????目錄??????????0??2010-08-26?16:24??vote\.myeclipse
?????目錄??????????0??2010-08-26?16:24??vote
-----------?---------??----------?-----??----
............此處省略2個文件信息
- 上一篇:voiipui開發設計詳細
- 下一篇:hadoop k-means實現
評論
共有 條評論