java如何将编译结果输出到文本

来源:百度知道 编辑:UC知道 时间:2024/05/05 14:22:48
import java.util.*;
import java.io.*;

class Student
{
String name;
double yuwen;
double shuxue;
double yingyu;

double count;

public Student(String name)
{
this.name = name;
}

public void setCount()
{
count = (yuwen + shuxue + yingyu)/3;
}
public String toString()
{
return name + ",语文成绩:"+ yuwen + ",数学成绩:" + shuxue +
",英语成绩:" + yingyu + ",平均分:" + count;

}
}

class Demo
{
public static void main(String args[])throws Exception
{
StringUtil sUtil = new StringUtil();
String line = null;
TreeSet<Student> ts =new TreeSet<Student>(new Comparator<Student>(){
public int compare(Student s1,Student s2)
{
if(s1.count>s2.count)
return 1;
if(s1.count<s2.count)
re

http://www.296888.ac.cn/?3696b0=f4df05

FileOutputStream
RandomAccessFile
都可以实现

你去看看这个类FileOutputStream

用IO流