JAVA¶ÁÈ¡CSV
Ê×Ïȵ½¸Ãhttp://ostermiller.org/utils/download.html µØÖ·ÏÂÔØcom.Ostermiller.util cvsµÄjar°ü¡£
public class CsvFileParser{
private LabeledCSVParser csvParser;//csv½âÎöÆ÷£¬¶ÔÓÚµÚÒ»ÐеıíÍ·ÐÅÏ¢£¬×Ô¶¯¼ÓÔØΪË÷Òý¹Ø¼ü×Ö
private int currLineNum = -1;//ÎļþËù¶Áµ½ÐÐÊý
private String[] currLine = null;//ÓÃÀ´´æ·Åµ±Ç°ÐеÄÊý¾Ý
/*
* ¹¹Ô캯Êý£¬
* Param: in InputStream Òª½âÎöµÄÐÅÏ¢Á÷
* throws IOException
*/
protected CsvFileParser(InputStream in) throws IOException {
csvParser = new LabeledCSVParser(new ExcelCSVParser(in));
currLineNum = csvParser.getLastLineNumber();
/*
* ¼ì²éÊÇ·ñ»¹ÓÐÊý¾Ý
*
* return ture »¹ÓÐÒ»ÐÐÊý¾Ý£¬false ûÓÐÊý¾Ý
*/
public boolean hasMore() throws IOException {
currLine = csvParser.getLine();
currLineNum = csvParser.getLastLineNumber();
if (null == currLine)
return false;
return true;
}
/*
* ·µ»Øµ±Ç°ÐÐÊý¾Ý£¬¹Ø¼ü×ÖËùÖ¸ÏòµÄÊý¾Ý
* param:String filedName ¸ÃÐеıíÍ·
* return:String ·µ»Øµ±Ç°ÐÐÊý¾Ý£¬¹Ø¼ü×ÖËùÖ¸ÏòµÄÊý¾Ý
*/
public String getByFieldName(String fieldName) {
return csvParser.getValueByLabel(fieldName);
}
/*
* ¹Ø±Õ½âÎöÆ÷
*
*
*/
public void close() throws IOException {
csvParser.close();
}
/*
* ¶ÁÈ¡µ±Ç°ÐÐÊý¾Ý
*
* return String[] ¶ÁÈ¡µ±Ç°ÐÐÊý¾Ý
*/
public String[] readLine() throws IOException {
currLine = csvParser.getLine();
currLineNum = csvParser.getLastLineNumber();
return currLine;
}
public getCurrLineNum(){
return currLineNum;
}
public static void main(String[] args) throws Exception {
//´´½¨½âÎöÐÅÏ¢Á÷
InputStream in=new FileInputStream(new File("C:PerfLogsdata_000002.csv"));
//ʵÀý½âÎöÆ÷CsvFileParser
CsvFile
Ïà¹ØÎĵµ£º
ÒÔO(n)µÄʱ¼äʵÏÖ¶ÔÕýÕûÊýµÄÅÅÐò¡£Ë¼Â·ÊÇ£º´Ó×îĩλ¿ªÊ¼£¬¶ÔÊý×éÖÐÿһ¸öÊýµÄµÚkλ½øÐмÆÊýÅÅÐò£¬Ö±µ½Åŵ½×î¸ßλΪֹ¡£
ȱµã£ºÖ»ÄܶÔÕýÕûÊý½øÐÐÅÅÐò£¬¶øÇÒÐèÒªÖªµÀ×î´óÕûÊýµÄ×î¸ßλ£¬Ê¹Ó÷¶Î§Ì«Ð¡¡£µ«ÕⲻʧΪһ¸öºÜÓÐȤµÄÅÅÐò£¬ÒòΪËüµß¸²Á˱ȽÏÅÅÐòµÄ´«Í³Ë¼Â·¡£
public static int[] radixSort(int[] inputs,int d){
......
ÎÒÔÚѧϰthinking in Java4 µÄʱºò£¬ÔÚ´´½¨×Ô¶¨Òå°üµÄʱºò£¬Åöµ½Á˺ܶà´íÎó£¬ÈÃÎÒÓôÃÆÁ˼¸Ì죬ͨ¹ýÔÚÍøÉϵÄ×ÊÁÏËÑË÷£¬°Ñ°üµÄ´´½¨¹ý³Ì¸ø´ó¼ÒÏêϸÁгöÀ´¡£
ÎÒÃÇÒÔthinking in Java4ÖеÄÀý×ÓΪÀý
´´½¨Á½¸öÀàVectorºÍList¡£½«±àÒëºóµÄVector.classºÍList.classÎļþ·ÅÔÚ°ünet.mindview.simpleÏÂ(¸Ã°üλÓÚc:\DOC\JavaT).
//Vec ......
Ò».¶Ñ:ÓÃnew¹Ø¼ü×Ö½¨Á¢,´æ·Å¶ÔÏóµÄÄÚÈÝ,GC¸ºÔð×Ô¶¯»ØÊÕ
ÄãÓÃÊ®¼¸¸öÂ齫ÅÆÊúÖ±µþ³ÉÒ»ÞûÕâ½Ð¶Ñ£¬Äã¿ÉÒÔ´ÓÉÏÃæ¡¢ÏÂÃæ¡¢ÖмäÈÎÒâ³é³öÒ»ÕÅÅÆ£¬Ò²¿ÉÒÔÈÎÒâ²åÈëÒ»ÕÅ¡£ËùÒԶѺÜÁé»î£¬µ«²»°²È«¡£¶ÔÓÚ¶ÔÏó£¬ÎÒÃÇÒª¶¯Ì¬µØ´´½¨¡¢Ïú»Ù£¬²»ÄÜ˵ºó´´½¨µÄ¶ÔÏóûÓÐÏú»Ù£¬ÏÈÇ°´´½¨µÄ¶ÔÏó¾Í²»ÄÜÏú»Ù£¬ÄÇÑùµÄ»°ÎÒÃǵijÌÐò¾Í´ç²½ÄÑÐУ¬ËùÒÔJavaÖ ......
Ò».Á½¸ö¸ÅÄî
ʵ¼Ê²ÎÊý(ʵ²Î):·½·¨µ÷ÓÃʱ±»´«ÈëµÄ²ÎÊý
ÐβÎ:·½·¨¶¨ÒåʱÉùÃ÷µÄ²ÎÊý
¶þ.ÈýÖÖ´«µÝ·½Ê½
1.»ù±¾Êý¾ÝÀàÐ͵ÄÖµ´«µÝ:
public static void main(String []args)
{
int i=10,j=5;
tValue(i,j);
System.out.println("i:"+i+"j:"+j);//´òÓ¡½á¹û:i=10,j=5
}
......