使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
来源:互联网 发布:二分搜索算法代码 编辑:程序博客网 时间:2024/06/06 05:58
import java.io.*;
import java.util.*;
//使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
public class Home {
public static final void main(String[] args) {
try {
File f = new File("exp.txt");
if(!f.exists()) {
f.createNewFile();
}
RandomAccessFile raf = new RandomAccessFile(f,"rw");
String str = new String();
System.out.println("请输入你想要输出的字母:");
str = new Scanner(System.in).next();
for(int i=0; i<str.length(); i++) {
raf.write(str.charAt(i));
}
raf.writeUTF(str);
long len = str.length();
while(0 != len--) {
raf.seek(len);
char ch = (char)raf.read();
System.out.print(ch+" ");
}
raf.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}
import java.util.*;
//使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
public class Home {
public static final void main(String[] args) {
try {
File f = new File("exp.txt");
if(!f.exists()) {
f.createNewFile();
}
RandomAccessFile raf = new RandomAccessFile(f,"rw");
String str = new String();
System.out.println("请输入你想要输出的字母:");
str = new Scanner(System.in).next();
for(int i=0; i<str.length(); i++) {
raf.write(str.charAt(i));
}
raf.writeUTF(str);
long len = str.length();
while(0 != len--) {
raf.seek(len);
char ch = (char)raf.read();
System.out.print(ch+" ");
}
raf.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}
0 0
- 使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
- 使用RandomAccessFile流将一个文本文件倒置读出
- 使用随机存取文件流:RandomAccessFile实现文本文件内容的随机插入
- RandomAccessFile类的使用,随机读写文件。
- 倒置读出文本文件JAVA实现
- 随机文件RandomAccessFile类
- 随机文件读取流RandomAccessFile
- 随机访问文件类RandomAccessFile
- 随机访问文件类RandomAccessFile
- 随机访问文件类RandomAccessFile
- 随机访问文件类RandomAccessFile
- IO流--RandomAccessFile--随机访问文件
- Java 文件随机访问类-RandomAccessFile
- RandomAccessFile类实现随机读写文件
- RandomAccessFile类学习,随机修改文件内容
- RandomAccessFile随机读写文件操作类讲解
- randomAccessFile随机文件
- RandomAccessFile 随机访问文件
- Qt Quick事件处理之鼠标、键盘、定时器
- World Wind Java开发之十三——加载Geoserver发布的WMS服务
- LR对事务状态的跟踪
- Spring进阶—如何用Java代码实现邮件发送(二)
- UVA - 11538 - Chess Queen (数论~)
- 使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
- Linux系统调用--fcntl函数详解
- 【CodeForce】509F Progress Monitoring(树形情景区间DP)
- Best Time to Buy and Sell Stock III (Java)
- shell写的日期函数
- oracle一个创建用户、创建表空间、授权、建表的完整过程
- linux的open函数
- CORS(跨域资源共享) 的配置
- Java String面试题