前言
明哥教学案例,本案例主要运用到IO流,引导学生学习Java知识,现记录下来,方便学生查询学习
一、效果图展示
![](https://img-blog.csdnimg.cn/20200812181911230.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDg0NTE2NQ==,size_16,color_FFFFFF,t_70)
二、代码实现
package com.mg.one;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* 类名:Write
* 包名:com.mg.one
* 创建时间:2020/6/29 15:57
* 创建人: 明哥
* 描述:
**/
public class Write {
private static String str1,str2;
private static long i=0;
private static boolean go = true;
public static void main(String[] args) throws IOException {
str1 = "D:/MG/AA";
str2 = str1+"a.txt";
do{
File file1 = new File(str1);
File file2 = new File(str2);
file1.mkdirs();//创建新文件夹
file2.createNewFile();//创建新文件
FileOutputStream file = new FileOutputStream(str2);
for(int j=0;j<1000;j++)
file.write(48);//向文件中写入码值为48的这个值(也就是写入0)
str1 = str1+"/";
for(long k=0;k<i;k++){
str1 = str1 +"a";
}
str1 = str1+i;
str2 = str1+"a.txt";
i++;
}while(go);
}
}