Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.karki.spring.dao.impl; import com.karki.spring.dao.PaymentDao; import com.karki.spring.entity.Payment; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.sql.SQLException; import java.util.List; import java.util.StringTokenizer; import org.springframework.stereotype.Repository; /** * * @author sharmila */ @Repository public class PaymentDaoImpl implements PaymentDao { @Override public void loadData(String path) throws IOException, ClassNotFoundException, SQLException { Payment payment = new Payment(); String line = ""; BufferedReader reader = new BufferedReader(new FileReader(new File(path))); while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, ","); payment.setPaymentId(Integer.parseInt(tokenizer.nextToken())); payment.setPaymentType(tokenizer.nextToken()); insert(payment); } reader.close(); } @Override public void exportData(String filename, String content) throws IOException, ClassNotFoundException, SQLException { FileWriter fileWriter = new FileWriter(new File(filename)); fileWriter.write(content); fileWriter.close(); } @Override public void insert(Payment payment) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public int update(Payment payment) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Payment getById(int batchId) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public int delete(int paymentId) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<Payment> getAll() throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<Payment> search(String param) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }