闺蜜说让我用代码写五万个对不起给她~~
import java.io.FileWriter;
import java.io.IOException;/**
* Created by lenovo on 2017/1/22.
* 1.常量字符串"对不起"
* 2.循环判定条件,五万字,使用count计数
* 3.创建文本文件并写入
*/
public class SorryForHui
{
public static void WriteToFile(String str , String url)
{
int count = 0;
try
{
FileWriter writer = new FileWriter(url,true);
while(count<50000){
writer.write(str);
count++;
}
writer.close();
}catch(IOException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
String sorry = "傻慧慧,我错啦~";
String url = "G:\\sorry.txt";
WriteToFile(sorry , url);
}
}