Java高级编程7-姜国海 流操作

java 不仅仅是编程语言

API:应用程序接口

①class File

文件:大小 名字 访问时间 创建时间 路径 
文件夹:是一个特殊的文件 大小为零 为其他文件夹提供存储信息
File(File parent, String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.
Eg:
File f1 = new File("c:\\");
File f2 = new File(f1,"a.txt");
file://c:\\a.dat 
file:// 文件访问协议

操作系统中保存的时间是一个长整数,单位毫秒

绝对路径和相对路径

一般用相对路径,提高程序的可移植性

②RandomAccessFile

可以将数据直接写入硬盘,不在缓存停留

③文本流

FileInputStream file = new FileInputStream(new File("a.txt"));

Reader:
FileReader fr = new FileReader("a.txt");
int c = fr.read();
char c2 = (char)c;



FileInputStream fis = new FileInputStream("a.txt");
InputStreamReader isr = new InputStreamReader(fis,"GBK");//自定义编码格式
BufferedReader br = new BufferedReader(isr );
String s = br.readLine();
import java.io.*;
public class WriteText {
    public static void main() throws Exception{
        FileOutputStream fos = new FileOutputStream("d:\\a.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos,"GBK");

    }
}

PrintWriter类

这里写代码片

PrintStream

这里写代码片

文本流的属性(配置)config

文件后缀名.properties

property 类
继承于map,但是不能调用put 只能接受字符串类型的键值对

String getProperty(String name);

setProperty(String name);
server = www.baidu.com

Eg:

Properties p = new Properties();
p.load()


p.setProperty("server","192.168.0.0");
注册表信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值