import java.io.*;
import java.lang.Byte;
import java.util.StringTokenizer;
class TestFile
{
public static void main(String args[])
{
String InFileName;
String OutFileName;
String strLine;
try
{
InFileName=args[0];
//System.out.println(InFileName);
FileReader mdFile = new FileReader(InFileName);
BufferedReader brdFile = new BufferedReader(mdFile);
double s=0;
double x,y ;
for(int a = 0 ; a < 11 ; a++)
{
strLine= brdFile.readLine();
System.out.println(strLine);
x=Double.valueOf(strLine).doubleValue();
s=s+x;
}
y=s/11;
System.out.println(s);
System.out.println(y);
StringTokenizer tokens = new StringTokenizer( InFileName, ".t");
OutFileName = tokens.nextToken() + ".w" + tokens.nextToken();
//System.out.println(OutFileName);
File myfile=new File(OutFileName);
myfile.createNewFile();
FileWriter fos= new FileWriter(OutFileName);
String str=Double.toString(y);
fos.write("平均 : "+str);
fos.flush();
fos.close();
}
catch (Exception e)
{
}
}
}
沒有留言:
張貼留言