创建student.txt
来源:互联网 发布:淘宝阿迪达斯高仿店 编辑:程序博客网 时间:2024/06/06 19:21
package to;import java.io.*; import java.util.Scanner;public class ReadString { static final String FileName="d:/student.txt"; public static void main(String[] args) throws IOException { // TODO 自动生成的方法存根 String str; InputStreamReader instr=new InputStreamReader(System.in); //定义输入文件类InputStreamReader BufferedReader bufred=new BufferedReader(instr); //定义读入缓冲器 BufferedReader OutputStreamWriter outstr=new OutputStreamWriter(System.out); //定义输出文件类OutputStreamWriter BufferedWriter bufwt=new BufferedWriter(outstr); //定义写入缓冲器BufferedWriter RandomAccessFile fisIn=new RandomAccessFile(FileName,"rw");//定义随机取类RandomAccessFile try{ System.out.println("请输入内容(按<Enter>结束):\n"); str=bufred.readLine(); //读入流对象通过调用方法readLine()实现按行读取信息 System.out.println("在路径 "+FileName+"中存储内容…\n"); fisIn.writeBytes(str); //将读取的信息写入文件流对象fisIn中 System.out.println("输出内容:\n"); bufwt.write(str); //将信息强制输出 bufwt.write((int)('\n')); //将信息强制输出 bufwt.flush(); //将信息强制输出 } catch(IOException ex){ System.out.println("输入/输出异常!"); } }}
阅读全文
0 0
- 创建student.txt
- Oracle创建student表
- 创建一个类Student
- 创建类Student和对象
- 创建类Student和对象
- 实现类Student的创建
- 创建类Student和对象
- 创建类Student和对象
- 创建类Student和对象
- 创建类Student和对象
- 创建类student和对象
- 创建Student类和对象
- 创建类Student和对象
- student
- student
- student
- student
- student
- 浅析Android下的Android.mk文件(三)
- 中国都有哪些顶级优秀的程序员?
- 菜鸟学习历程【7】 指针数组、数组指针、main命令行
- 接口
- C++对象和类笔记
- 创建student.txt
- 数据结构实验之图论一:基于邻接矩阵的广度优先搜索遍历
- 大数据架构:flume-ng+Kafka+Storm+HDFS 实时系统组合
- 函数的三种角色
- PHP增删改查完成感想
- i++和++i的那些陷阱坑
- 51nod 1307 绳子与重物 二分+dfs
- C++调python
- 哈夫曼树(数据结构)