请帮我看下这个程序,怎样才读到文件里,急!!!!!!!!!!!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/05 05:11:55
import java.io.*;

class Student
{
final int M = 100;
String name[] = new String [M];
float scor1[] = new float [M];
float scor2[] = new float [M];
float scor3[] = new float [M];
float scor4[] = new float [M];
float sum[] = new float[M];
float sin[] = new float[M];

Student()
{
}
public void input()
{
try
{
File file = new File("input.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

char ch = ' ';
int i= 0;

//file.createNewFile("input","txt");
if(file.exists())
{
System.out.println("can't found this file");
}
do
{
System.out.print("请输入学生姓名:");
if(i < M)
{
name[i]=in.readLine();
out.write(name[i]);
}
System.out.print(&qu

File file = new File("input.txt");
上面这句如果不指定路径的话,因该把这个文件放在编译后的Student.class相同的目录里面就可以了。生成的input.txt也会在这里。