java读取内存中的csv文件,跳过第一行

package ApacheCommonCSV;
import junit.framework.TestCase;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.List;

public class AppTest extends TestCase
{

    public void testApp(){
        try {
            FileReader filereader = new FileReader("/Users/student/Desktop/file.csv");
            BufferedReader bufferedReader = new BufferedReader(filereader);
            bufferedReader.readLine();// try-catch omitted
            CSVFormat format = CSVFormat.DEFAULT.withDelimiter(',');
            CSVParser parser = new CSVParser(bufferedReader, format);
            List records = parser.getRecords();//跳过第一行所有行的记录
            for(int i=0;idouble[] temp=new double[records.get(i).size()];
                for(int j=0;j//System.out.print(temp[j]+" ");
                }
                for(int ii=0;ii"  ");
                }
                System.out.println();
            }
        }catch (Exception e){
            System.out.print("please check your upload");
        }

    }
}

<dependency>
      <groupId>org.apache.commonsgroupId>
      <artifactId>commons-csvartifactId>
      <version>1.5version>
dependency>

你可能感兴趣的:(java)