文件的读写1
来源:互联网 发布:传智播客52期php下载 编辑:程序博客网 时间:2024/06/09 17:31
地址 d:/linshi/suibianxie
package Practice170518_IO;import java.io.*;import static java.lang.System.*;import java.util.*;/** * * @author Zhu Zhengyan */public class practice1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); out.println("please enter the adress of the fail"); String adress =new String(in.nextLine()); try { FileOutputStream a = new FileOutputStream(adress); DataOutputStream b = new DataOutputStream(a); out.println("please enter 5 float numbers:"); for(int i = 0;i<5;i++) { float shu = in.nextFloat(); b.writeFloat(shu); } } catch(Exception e) { out.println("Exception"+e); } out.println("you have create a file."); //read it try { FileInputStream c = new FileInputStream(adress); DataInputStream d = new DataInputStream(c); float[] nums = new float[5]; for(int i = 0;i<5;i++) { nums[i] = d.readFloat(); } c.close(); Arrays.sort(nums); out.print("they are:"); out.println(Arrays.toString(nums)); } catch(Exception e) { out.println("Exception"+e); } try { FileOutputStream e = new FileOutputStream(adress) ; DataOutputStream f = new DataOutputStream(e); for(int i = 0;i<5;i++) { float shu = in.nextFloat(); f.writeFloat(shu); } } catch(Exception e) { out.println("Exception"+e); } }}
阅读全文
0 0
- 文件的读写1
- 文件的读写1
- 文件的读写操作1
- 文件操作《1》文件的读写
- MFC 文件操作1 文件的读写
- 串口的读写,文件读写
- 【1】文件流的读写操作
- INI文件的读写
- 读写文件的例子
- INI文件的读写
- 关于文件的读写
- 文件的读写操作
- 文件的读写操作
- properties文件的读写
- 读写服务器端的文件
- 位图文件的读写
- C++文件的读写
- ini文件的读写
- CSS3学习笔记-选择器
- 线段树专题
- lxc的简单介绍和使用
- 51nod 1201[整数划分] 1259[整数划分V2] 1597 [有限背包计数问题]
- 享元模式
- 文件的读写1
- 最短路径之Dijkstra算法的概念与实现
- Kotlin基础知识一
- 关于javascript的块级作用域
- 树梅派-声音传感器示例(Python)
- C++代码随笔
- JVM类文件结构
- Akka(24): Stream:从外部系统控制数据流-control live stream from external system
- [笔记分享] [RPM] RPM debug log