package com.ycx.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class WriterFile {
public static void main(String[] args) throws IOException {
WriterFile rf = new WriterFile();
//Class.NewInstance(WriterFile);
// rf.readerfile();
rf.writefile();
}
/*public void readerfile() {
String s = "C:/1.txt"; //H:/stringurl.txt
String getStringline = null;
Scanner scanner = null;
int count = 1;
try {
BufferedReader reader = new BufferedReader(new FileReader(s));
BufferedWriter bw = new BufferedWriter(new FileWriter(
"c:/stringl.txt"));
scanner = new Scanner(reader);
while (scanner.hasNextLine()) {
getStringline = scanner.nextLine();
count++;
//for (int i = 1; i <= count; i++) {
s = reader.readLine();
System.out.println(getStringline);
System.out.println("==============");
// String torep = getStringline.replace("Android+Open+Source+Project", "");
String torep = getStringline.replace("N", "");
//String torep2 = getStringline.replace("Android+Open+","--------");
System.out.println(torep);
bw.append(torep+"/r/n");
//bw.append(torep2+" ");
// char[] buffer = new char[4096];
// bw.write(buffer, 0, len);
//bw.write();
// }
}
System.out.println(count);
bw.flush();
bw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}*/
public void writefile() throws IOException {
int count = 1;
BufferedWriter bw = new BufferedWriter(new FileWriter(
"c:/string_YN.txt"));
for(int i=1;i<=30;i++){
String torep = null;
/*if(i<10){
torep = "2"+"000"+i +"|Test Description 1|Y|TEST 1|N|Y|皜祈岫 1|N";
}else if(i<100){
torep = "2"+"00"+i +"|Test Description 1|Y|TEST 1|N|Y|皜祈岫 1|N";
}else if(i<1000){
torep = "2"+"0"+i +"|Test Description 1|Y|TEST 1|N|Y|皜祈岫 1|N";
}else{
torep = "2"+i +"|Test Description 1|Y|TEST 1|N|Y|皜祈岫 1|N";
}*/
if(i%2 == 0){
torep = " INSERT INTO `admin` VALUES (i+1, '00000000001', 'vv', 'bb', '1', '1', null)";
System.out.println(torep);
bw.append(torep+"/r/n");
count++;
} else if(i%3 == 0){
torep = " INSERT INTO `admin` VALUES (i+1, '00000000001', 'vv', 'bb', '0', '1', null)";
System.out.println(torep);
bw.append(torep+"/r/n");
} else{
torep = " INSERT INTO `admin` VALUES (i+1, '00000000001', 'vv', 'bb', '1', '0', null)";
System.out.println(torep);
bw.append(torep+"/r/n");
}
}
System.out.println(count);
bw.flush();
bw.close();
}
}
IO-1
最新推荐文章于 2024-05-07 11:26:34 发布