Java文本文件倒置输出

p321  4.(1)

import java.io.*;
public class E {
   public static void main(String args[]) {
       File f=new File("E.java");;
       try{   RandomAccessFile random=new RandomAccessFile(f,"rw");
              random.seek(0);
              long m=random.length();
              while(m>=0) {
                  m=m-1;
                  random.seek(m);
                  int c=random.readByte();
                  if(c<=255&&c>=0)
                     System.out.print((char)c);
                  else {
                    m=m-1;
                    random.seek(m);
                    byte cc[]=new byte[2];
                    random.readFully(cc);
                    System.out.print(new String(cc)); 
                  }
              }
       }
       catch(Exception exp){}
    }
}

猜你喜欢

转载自blog.csdn.net/gayhang/article/details/80946754