File source = new File("f:/test.txt");
File tar = new File("f:/test2.txt");
try {
BufferedReader bReader = new BufferedReader(new FileReader(source));
BufferedWriter bw = new BufferedWriter(new FileWriter(tar));
String line = "";
while ((line = bReader.readLine()) != null) {
line = line.trim();
line = URLEncoder.encode(line, "UTF-8");
bw.write(line);
bw.newLine() ;
bw.flush();
}
bReader.close() ;
bw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}