package FileT.Day2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileInputTest {
public static void main(String[] args) throws IOException {
FileInputStream f1 = new FileInputStream("fox.txt");
int n;
while ((n =f1.read())!=-1){
System.out.print((char) n);
}
f1.close();
}
}
class da{
public static void main(String[] args) {
byte a =-128;
int b =128;
System.out.println((char)a);
System.out.println((char)b);
}
}
class demo{
public static void main(String[] args) throws IOException {
FileInputStream f1 =new FileInputStream("D:\\新建文件夹\\WeChat Files\\wxid_k4lpvlwhf7m222\\FileStorage\\File\\2021-07\\统计学PPT\\统计学数据.xlsx");
FileOutputStream f2 =new FileOutputStream("D:\\新建文件夹\\WeChat Files\\wxid_k4lpvlwhf7m222\\FileStorage\\File\\2021-07\\统计学数据.xlsx");
int n;
while ((n =f1.read())!=-1){
f2.write(n);
}
f1.close();
f2.close();
}
}
package FileT.Day2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileInputTEst2 {
public static void main(String[] args) throws IOException {
FileInputStream f1 =new FileInputStream("fox.txt");
byte [] b =new byte[5];
int r1 = f1.read(b);
System.out.println(r1);
for (byte a :b) {
System.out.print((char)a);
}
int r2 = f1.read(b);
System.out.println(new String(b));
int read = f1.read(b, 2, 2);
System.out.println(read);
System.out.println(new String(b));
f1.close();
}
}
package FileT.Day2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileInputTest3 {
public static void main(String[] args) throws IOException {
long first =System.currentTimeMillis();
FileInputStream f1 =new FileInputStream("D:\\picture\\捕获2.PNG");
FileOutputStream f2 =new FileOutputStream("D:\\新建文件夹\\WeChat Files\\wxid_k4lpvlwhf7m222\\FileStorage\\File\\2021-07\\捕获2.PNG");
int n;
while ((n =f1.read())!=-1){
f2.write((byte)n);
}
f1.close();
f2.close();
long end =System.currentTimeMillis();
System.out.println(end-first);
long first1 =System.currentTimeMillis();
FileInputStream f3 =new FileInputStream("D:\\picture\\捕获3.PNG");
FileOutputStream f4 =new FileOutputStream("D:\\新建文件夹\\WeChat Files\\wxid_k4lpvlwhf7m222\\FileStorage\\File\\2021-07\\捕获3.PNG");
byte[] bys =new byte[1024];
int n1;
while ((n1 =f3.read(bys))!=-1){
f4.write(bys,0,n1);
}
f3.close();
f4.close();
long end1 =System.currentTimeMillis();
System.out.println(end1-first1);
}
}