package com.zqj;
import java.io.FileOutputStream;
public class outputToTxe {
public static void main(String[] args)
{
try
{
FileOutputStream fos = new FileOutputStream("d:/hello.txt "); // 输出位置。如果是循环输出 创建文档要写在循环外 同时加上捕获异常
String str = "hello,this is a test! ";
fos.write(str.getBytes());
fos.close(); //如果要循环输出 则不要关闭流 避免不能取得全部数据
}
catch(Exception e)
{
e.printStackTrace();
}
}
}