```java
// 使用File对象创建流对象
File file = new File(".\\day_09\\a.txt");
new FileOutputStream(file).write("还是写一点东西吧".getBytes());
FileInputStream fos = new FileInputStream(file);
// 使用文件名称创建流对象
FileInputStream fos2 = new FileInputStream(".\\day_09\\a.txt");
```
```java
FileInputStream fos2 = new FileInputStream(".\\day_09\\a.txt");
int len;
byte[] b = new byte[7];
while ((len = fos2.read(b)) != -1) {
System.out.println(new String(b).substring(0, len));
// 也可以使用 new String(b, 0, len);
}
// Courier进行数据传递
class Courier {
long size;
long receive;
public Courier(long size){
this.size = size;
receive = 0;
}
}
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
int len; // 记录返回的字节大小。
byte[] temp = new byte[1000]; // 记录字节数据。
Random random = new Random();
// 使用文件名称创建流对象
File file = new File(".\\day_09\\feifei.jpg");
FileInputStream in = new FileInputStream(file);
FileOutputStream out = new FileOutputStream(".\\day_09\\newfeifei.jpg", true);
// new 一个数据传递对象。
Courier courier = new Courier(file.length());
Runnable r = () -> {
Courier cour = courier;
int n = 25; // 进度条的长度
while (true) {
long computd = courier.receive;
long exists = computd * n / courier.size;
long i = 0;
System.out.print("[");
for(;i <= exists; i++) System.out.print(">");
for(;i < n; i++) System.out.print("-");
```java
// GBK: One Character(我)
String line;
InputStreamReader isr = new InputStreamReader(new FileInputStream("GBK.txt"), "GBK");
BufferedReader br = new BufferedReader(isr);
line = br.readLine();
br.close();
isr.close();
System.out.println("content:" + line + "GBK OutMemory 2; In JVM: " + line.getBytes().length + " bytes");
//GBK: One Character(我)
InputStreamReader isr2 = new InputStreamReader(new FileInputStream("UTF-8.txt"), "UTF-8");
BufferedReader br2 = new BufferedReader(isr2);
line = br2.readLine();
br2.close();
isr2.close();
System.out.println("content:" + line + "UTF-8 OutMemory 3; In JVM: " + line.getBytes().length + " bytes");