展开全部
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
*@author young
*@Description:
*/
public class Test {
public static void main(String[] args) {
62616964757a686964616fe58685e5aeb931333339666165File file = null;
FileWriter fw = null;
BufferedReader br = null;
String str = null;
List list = new ArrayList();
try {
file = new File("e:\\IP.txt");
br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
while((str = br.readLine()) != null){
str = "http://" + str;
System.out.println(str);
list.add(str);
}
br.close();
if(file.exists()){
file.delete();
file.createNewFile();
}
fw = new FileWriter(file, true);
for(int i = 0; i
fw.write(list.get(i));
fw.write("\r\n");
fw.flush();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(fw != null){
try {
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
执行代码之后结果