import java.io.*; import java.util.*; public class SqlWriter { public SqlWriter() { try{ StringBuffer buff = new StringBuffer(); BufferedReader in = new BufferedReader( new FileReader( "c:\\data\\data\\query2.txt" )); BufferedWriter out = new BufferedWriter( new FileWriter( "C:\\data\\data\\query2.sql" )); String data; String sql; while( (data=in.readLine())!= null ){ sql = createSQL(data); //System.out.println( sql ); out.write(sql); out.newLine(); } in.close(); out.flush(); out.close(); }catch(Exception ex){ ex.printStackTrace(); } } private String createSQL( String source ){ StringTokenizer t = new StringTokenizer( source, "\t" ); StringBuffer sql = new StringBuffer(); sql.append( "insert into vehicle values('" ); for (int i=0;i<9;i++){ sql.append( t.nextToken() ); sql.append( "','" ); } sql.append( t.nextToken() ); sql.append( "');" ); return sql.toString(); } public static void main(String[] args) { SqlWriter sqlWriter1 = new SqlWriter(); } }