文件的路径问题
import java.io.*;
public class CopyFile {
public static void main(String[] args) {
try{
//File f = new File("/");
//System.out.println(f.getAbsolutePath());
FileInputStream fis = new FileInputStream("CopyFile.java");
FileOutputStream fos = new FileOutputStream("temp.txt");
int read = fis.read();
while(read!=-1)
{
fos.write(read);
read = fis.read();
}
fis.close();
fos.close();
}catch(IOException e)
{
System.out.println(e.getMessage());
}
}
}
结果是找不到文件CopyFile.java,我本来的意思是指当前目录,后来加了上面注释掉的两行
File f = new File("/");
System.out.println(f.getAbsolutePath());
显示当前目录居然是在D:下面,可我的程序明明不在D盘下面啊