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.FacilitiesDao; import com.karki.spring.entity.Facilities; 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 FacilitiesDaoImpl implements FacilitiesDao { @Override public void loadData(String path) throws IOException, ClassNotFoundException, SQLException { Facilities fa = new Facilities(); String line = ""; BufferedReader reader = new BufferedReader(new FileReader(new File(path))); while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, ","); fa.setFacilityId(Integer.parseInt(tokenizer.nextToken())); fa.setName(tokenizer.nextToken()); fa.setFee(Double.parseDouble(tokenizer.nextToken())); insert(fa); } 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 int insert(Facilities facilities) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public int update(Facilities facilities) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Facilities 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 facilitiesId) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<Facilities> getAll() throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<Facilities> search(String param) throws ClassNotFoundException, SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }