题目:把九九乘法表输出到当前目录下的99.txt文件中
public class Nine_Nine {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
FileOutputStream fos=new FileOutputStream("99.txt");
for(int i=1;i<=9;i++) {
for(int j=1;j<=i;j++) {
StringBuffer sb=new StringBuffer();
sb.append(j).append("*").append(i).append("=").append(j*i).append("\t");
byte[] b=sb.toString().getBytes();
fos.write(b);
}
fos.write("\n".getBytes());
}
fos.close();
}
}
|
|