import com.opencsv.CSVWriter;
import java.io.FileWriter;
import java.io.IOException;
public class CSVExporter {
public static void main(String[] args) {
String csvFile = "students.csv";
String[][] students = {
};
try (CSVWriter writer = new CSVWriter(new FileWriter(csvFile))) {
for (String[] student : students) {
writer.writeNext(student);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
import com.opencsv.CSVReader;
import java.io.FileReader;
import java.io.IOException;
public class CSVImporter {
public static void main(String[] args) {
String csvFile = "students.csv";
String[] line;
try (CSVReader reader = new CSVReader(new FileReader(csvFile))) {
while ((line = reader.readNext()) != null) {
String name = line[0];
int age = Integer.parseInt(line[1]);
double score = Double.parseDouble(line[2]);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.5.2</version>
</dependency>
implementation 'com.opencsv:opencsv:5.5.2'