解析CSV行
//package com.nowjava;/**n o w j a v a . c o m**/ public class Main { public static String[] parseCSVLine(String line) { String[] field = new String[12]; String temp = ""; int index = 0; boolean hasQuotation = false; for (int i = 0; i < line.length(); i++) { Character currentChar = line.charAt(i); if (currentChar.equals('\"')) { hasQuotation = !hasQuotation; } if (currentChar.equals(',')) { /** from 时 代 Java 公 众 号 - nowjava.com**/ if (!hasQuotation) { field[index] = temp; temp = ""; index = index + 1; } else { temp = temp + line.charAt(i); } } else { temp = temp + line.charAt(i); }