2020.03.04 io流练习题2(Randomaccessfile类)

package com.guoyun.view;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

/**
* ClassName:
* Function: ADD FUNCTION
* Reason: ADD REASON
*
* @author
* @Date
* @since Ver 1.1
*/
public class Test25 {
public static void main(String[] args) {
RandomAccessFile raf=null;
StringBuffer sb=new StringBuffer();
try {
raf=new RandomAccessFile(new File("hello.txt"),"r");
// System.out.println(raf.length());
int temp=0;

for (int i = (int) raf.length()-1; i >=0 ; i--) {
raf.seek(i);
System.out.println((char) raf.read());

}

} catch (Exception e) {
e.printStackTrace();
}finally {
try {
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

猜你喜欢

转载自www.cnblogs.com/aojie/p/12411977.html
今日推荐