特别重要的六行代码:
fileinputstream fis = new finleinputstream("xxx.txt")
int x = fis.read();
system.out.println(x)
int y = fis.read()
system.out.println(y)
int z = fis.read();
system.out.println(z);
int a = fils.read();
system.out.println(b);
fis.close();
_____________________________________________
fileinputstream fis = new finleinputstream("xxx.txt")
int b ;
while(b = fis.read() !=-1)
system.out.println(b)
public int read(byte[] bys); //一次读一个数组
available(); // 获取要读的文件的所有字节数
fileinputstream fis = new fileinputstream("双招传送重生.jpg")
fileoutputstream fos = new fileoutputstream("copy.mp3")
//int len = fis.available();
//system.out.println(len)
public void write (byte[] bys , int index , int length);
一次读一个指定长度的字节数组
fileinputstream fis = new fileinputstream("xxx.txt")
byte[] arr = new byte[2];
int a = fis.read(arr); // 将文件上的字节读到字节数组中
System.out.println(a);
for(byte b = arr)
system.out.println(b)
int c = fis.read(arr)
system.out.println(c)
for(byte b = arr)
System.out.println(b)
fis.close();
fileinputstream fis = new fileinputstream("xxx.txt")
fileoutputstream fos = new fileoutputstream("yyy.txt")
byte[] arr = new byte[2]
int len;
while((len = fis.read(arr))!= -1)
fos.write(arr,0,len);
bufferedoutputstream bos = new bufferedoutputstream(new fileoutputstream)
加强版
public class Demoshittoo {
public static void main(String[] args) throws IOException {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\迅雷下载\\[刀剑神域.第二季].[DMG][Sword.Art.Online.II][07][720P][GB](ED2000.COM).mp4"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("copy.mp4"));
int b;
while((b = bis.read()) != -1) {
bos.write(b);