renameto
import java.io.*;import java.util.Date;
class attributes{
static void fileData(File f) {
System.out.println("get name :"+f.getName()+"\nget parent dir:"+f.getParent()+"\nget last Modified date"+new Date(f.lastModified())+"\nget length :"+f.length());
}
}
public class myfileHomework4{
public static void main(String[] args) throws IOException {
File now=new File(args[0]);
attributes.fileData(now);
String temp;
long fpointer=0;
RandomAccessFile rf =new RandomAccessFile(now, "rw");
while(fpointer<rf.length()) {
fpointer=rf.getFilePointer();
temp=rf.readLine();
if(temp.equals("development")) break;
}
rf.seek(fpointer);
rf.writeBytes("java coding");
File comeon=new File(args[1]);
System.out.println("是否修改成功:"+now.renameTo(comeon)); //不知道为什么就是改不了
}
}
不知道为什么就是改不了