- public static void main(String[] args){
- try {
- BufferedReader br=new BufferedReader(new FileReader(new File("e:/ime.txt")));
- OutputStream os=new FileOutputStream(new File("e:/sql.txt"));
- byte[] buf2={13,10};//换行
- String line="";
- while((line=br.readLine())!=null){
- String[] arr=line.split(" ");
- int len=arr.length;
- String spell="";
- String initial="";
- for(int i=3;i<len;i++){
- spell+=arr[i];
- initial+=arr[i].charAt(0);
- }
- String insertSql="insert into match_word(word,initial,spell,store_state,sync_state,mark_times, use_times, state) values('"+arr[0]+"','"+initial+"','"+spell+"', '已入库', '已同步',0, 0,'正常');";
- os.write(insertSql.getBytes());
- os.write(buf2);
- }
- br.close();
- os.flush();
- os.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/0910201410584.html
来源: http://www.codesnippet.cn/detail/0910201410584.html