qq_童化金_dwxHIS
2019-03-12 15:57
import java.io.*;
class FileInOutEx{
public static void main(String[] args) throws IOException{
File file_Book1 = new File("Book1.txt");
String bookInfo = "世界是平的\t 350.0\t Friedman\t";
file_Book1.createNewFile();
FileOutputStream fos = new FileOutputStream(file_Book1);
fos.write(bookInfo.getBytes());
fos.close();
FileInputStream fis = new FileInputStream(file_Book1);
System.out.println("书籍名称\t 价格\t 作者\t");
System.out.println("---------------------------------------");
int i = 0;
while((i=fis.read()) != -1)
System.out.print((char)i);
fis.close();
}
}
package com.imooc;
import java.io.File;
import java.io.*;
public class FileInOutEx {
public static void main(String[] args) throws IOException{
File file_Book1 = new File("Book1.txt");
byte[] bookInfo = "世界是好的\t 350.0\t Friedman\t".getBytes();
file_Book1.createNewFile();
FileOutputStream fos = new FileOutputStream(file_Book1);
fos.write(bookInfo);
fos.close();
FileInputStream fis = new FileInputStream(file_Book1);
byte[] byt = new byte[1024];
System.out.println("书籍名称\t 价格\t 作者\t");
System.out.println("---------------------------------------");
int i = fis.read(byt);
System.out.print(new String(byt,0,i));
fis.close();
}
}
Java入门第三季
409792 学习 · 4340 问题
相似问题