import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Test {
public static void main(String[] args) throws Exception {
InputStreamReader isr = new InputStreamReader(new FileInputStream(
new File("c:/outman/1.txt")));
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
new File("c:/outman/2.txt")));
int c;
while ((c = isr.read()) != -1) {
byte[] bs = String.valueOf((char) c).getBytes("utf-8");
StringBuffer buffer = new StringBuffer();
for (byte b : bs) {
String s = Integer.toHexString(b & 0xff);
buffer.append("%" + s.toUpperCase());
}
osw.write(buffer.toString());
}
isr.close();
osw.close();
}
}
错误
Exception in thread "main" java.io.FileNotFoundException: c:\outman\1.txt (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.
at com.justin.day01.Test.main(Test.java:12)
关键是// \\ \ / 全都试过了呀 依然是一样的结果