?? filereadertest.java~16~
字號(hào):
package net.bishe.file;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
import java.sql.*; // JDBC package
//import com.microsoft.jdbc.sqlserver.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Hashtable;
public class FileReaderTest {
public static void main(String[] args) throws Exception {
int aa; ////////////////////
int i; ///////////////////
FileReaderTest test=new FileReaderTest();
try
{
test.readLineFile("d:\\","Winpy1.txt");
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void readLineFile(String filePath, String fileName)
throws IOException
, SQLException {
Connection con;
Statement stat=null;
ResultSet rs;
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:sjy", "", "");
stat = con.createStatement();
}
catch (ClassNotFoundException e) {}
// Connetion con=DriverManager.getConnection("jdbc:odbc:sjy","","");
FileReader fr = new FileReader(filePath + fileName);
BufferedReader br = new BufferedReader(fr);
String line = br.readLine();
while (line != null)
{
System.out.println(line);
line = br.readLine();
if(line!=null)
{
String hanzi=line.substring(0,1);
String pinyin=line.substring(1,line.length());
// for(int i=1;i<10;i++) //////////
// {
// String pinyin=line.substring(i,i+1);
// if(pinyin='a'||'b'||'c'||'d'||'e'||'f'||'g'||'h'||'i'||'j'||'k'||'l'||'m'
// ||'n'||'o'||'p'||'q'||'r'||'s'||'t'||'u'||'v'||'w'||'x'||'y'||'z')
// {
// }
// else int aa=++i;
// }
// String pinyin=line.substring(1,aa);
// String bihua=line.substring(aa,line.length() ); //////////
String insertstr="insert into pinyin (hanzi,pinyin) values ('"+hanzi+"','"+pinyin+"')";
try
{
stat.execute(insertstr);
}
catch (SQLException e3)
{
// TODO Auto-generated catch block
e3.printStackTrace();
}
}
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -