Saturday, December 20, 2008

原创:终于解决java中io类中的的相对路径问题




经过不断尝试终于得到了java中IO的的相对路径问题
啥也不说看例子吧
public static void main(String[] args) {
  try {
   FileInputStream fin = new FileInputStream(".\\src\\Hello.java");
  
   FileOutputStream fou = new FileOutputStream("./src/hh.java");
   while (fin.read()!=-1) {
    int b=fin.read();
    fou.write(b);
    System.out.print((char)b);
    
   }
   fin.close();
   fou.close();
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  
 }

No comments: