import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class q13{
public static void main(String[] args) {
String path = "D:\\Demo1.txt";
File file = new File(path);
try{
file.createNewFile();
}catch (Exception e){
e.printStackTrace();
}
}
@Test
void Dic(){
String path = "D://C";
File file = new File(path);
if (!file.exists()){
file.mkdirs();
}
}
@Test
void DeleteDic(){
String path = "D://C";
File file = new File(path);
if (file.exists()){
file.delete();
System.out.println("删除成功");
} }
@Test
void FlieInputStreamTest(){
String path = "D:\\Demo1.txt";
FileInputStream fileInputStream = null;
int read = 0;
byte[] b =new byte[2];
try {
fileInputStream = new FileInputStream(path);
while((read = fileInputStream.read(b))!=-1){
System.out.println( new String(b,0,read) );
}
}catch (Exception e){
e.printStackTrace();
}finally{
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}