public void readCsv(String fileName, int passHead) {
CSVReader reader;
try {
reader = new CSVReader(new FileReader(fileName));
String [] nextLine;
for(int i=0; i<passHead; i++) reader.readNext();
while ((nextLine = reader.readNext()) != null) {
System.out.println(nextLine[0]);
System.out.println(nextLine[1]);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void writeCsv(String fileName) {
try {
CSVWriter writer;
writer = new CSVWriter(new FileWriter(fileName));
String[] entries = new String[10];
entries = "first#second#third".split("#");
writer.writeNext(entries);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
CSVReader reader;
try {
reader = new CSVReader(new FileReader(fileName));
String [] nextLine;
for(int i=0; i<passHead; i++) reader.readNext();
while ((nextLine = reader.readNext()) != null) {
System.out.println(nextLine[0]);
System.out.println(nextLine[1]);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void writeCsv(String fileName) {
try {
CSVWriter writer;
writer = new CSVWriter(new FileWriter(fileName));
String[] entries = new String[10];
entries = "first#second#third".split("#");
writer.writeNext(entries);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
'Java' 카테고리의 다른 글
java socket 통신 (2) | 2010.04.07 |
---|---|
lotto 당첨번호 파싱 (4) | 2010.04.07 |
AES java 암호화 구현 function sample (1) | 2010.04.07 |
Unzip.java (3) | 2010.04.07 |
PropertyLoader.java (2) | 2010.04.07 |