Java read CSV file sample sharing (Java parsing csv file) _java

Source: Internet
Author: User

Copy Code code as follows:

Import java.io.*;
Import java.util.*;
public class Handlecsv {
public static void Main (string[] args) throws IOException {
BufferedReader br = new BufferedReader (
New InputStreamReader (
New FileInputStream ("Test.csv")
)
);

String Line;
String name;
String age;
String birthday;
while (line = Br.readline ())!= null) {
System.out.println (line);
String[] Info = line.split (",");
Name = Info[0].trim ();
Age = Info[1].trim ();
Birthday = Info[2].trim ();
System.out.print (name + "T" + Age + "T" + birthday + "\ n");
}
}
}


CSV file
Copy Code code as follows:

Alice, 22, 1992/03/05
Bob, 33, 1981/11/21
Cart, 40, 1974/07/13

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.