CreateForIn.java

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CreateForIn {

 private static FileWriter fw = null;

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

String inputFile = “C:\\InSQLInput.txt”;
String input=””;
try {
readALineAtATime(inputFile);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

    private static void readALineAtATime(String inputFile) throws FileNotFoundException, IOException {

BufferedReader br = new BufferedReader(new FileReader(inputFile));
String line;
System.out.println(“Begin:::”);
while ((line = br.readLine()) != null) {
genSQL(line);

}
br.close();
fw.close();
System.out.println(“End:::”);

}

 private static void genSQL(String line) {

try{
// TODO Auto-generated method stub
String newValue = “‘”+line.trim()+”‘,”;
writeToFile(newValue);
}catch(Exception e){
e.printStackTrace();
}

}

private static void writeToFile(String line) {
// TODO Auto-generated method stub
//BufferedWriter br = new BufferedReader(new FileReader(inputFile));
try {
if (fw == null)
fw = new FileWriter(“C:\\InSQLOutput.txt”);
fw.append(line);
fw.append(“\n”);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.