package yuwenzhi.javaUtils;
import java.io.BufferedReader;
import java.io.FileReader;
public class ShowCreateTable {
public static void main(String[] args) {
long startTime = System.nanoTime(); //
test(); //
long endTime = System.nanoTime(); //
System.out.println(" :" + (endTime - startTime) + "ns"); //
}
public static void test() {
try {
FileReader reader = new FileReader("f:/test.txt");
BufferedReader bufferedReader=new BufferedReader(reader);
String line;
String[] lineArray;
int count=1;
StringBuilder stringBuilder=new StringBuilder();
stringBuilder.append("create table test(");
while((line=bufferedReader.readLine())!=null) {
lineArray=line.split("\\s+");
stringBuilder.append(lineArray[0]+" ");
if(lineArray[1].toLowerCase().equals("varchar")|| lineArray[1].toLowerCase().equals("int")) {
stringBuilder.append(lineArray[1]+"("+lineArray[2]+")");
}
if(lineArray[1].toLowerCase().equals("datetime")) {
stringBuilder.append(lineArray[1]);
}
if(lineArray.length==4) {
stringBuilder.append(" not null,");
}else {
stringBuilder.append(",");
}
count++;
}
stringBuilder.append("primary key(8888,78888));");
System.out.println(stringBuilder.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}