read csv file with java - comma delimiter in text field

前端 未结 4 1349
逝去的感伤
逝去的感伤 2020-12-22 10:29

I have a comma separated CSV file contains NASDAQ symbols . I use Scanner to read a file

  s = new Scanner(new File(\"C:\\\\nasdaq_companylist.csv\")).useD         


        
4条回答
  •  不知归路
    2020-12-22 11:26

    Unless this is homework you should not parse CSV yourself. Use one of existing libraries. For example this one: http://commons.apache.org/sandbox/csv/

    Or google "java csv parser" and choose another.

    But if you wish to implement the logic yourself you should use negative lookahead feature of regular expressions (see http://download.oracle.com/javase/1,5.0/docs/api/java/util/regex/Pattern.html)

提交回复
热议问题