当前位置: 技术问答>java相关
书上的程序,我确编译不了,help?
来源: 互联网 发布时间:2015-04-01
本文导语: import java.io.*; public class CopyFile { public static void main(String args[]) throws Exception {BufferedReader br=new BufferedReader(new FileReader("shi.txt")); BufferedWriter bw=new BufferedWriter(new FileWriter("person.txt")); ...
import java.io.*;
public class CopyFile
{
public static void main(String args[]) throws Exception
{BufferedReader br=new BufferedReader(new FileReader("shi.txt"));
BufferedWriter bw=new BufferedWriter(new FileWriter("person.txt"));
String s,space=" ";
int num=0;
while(br.ready())
{s=br.readLine();
num++;
bw.writer(String.valueOf(num));
bw.write(space);
bw.write(s);
bw.newLine;
}
bw.close();
}
}
public class CopyFile
{
public static void main(String args[]) throws Exception
{BufferedReader br=new BufferedReader(new FileReader("shi.txt"));
BufferedWriter bw=new BufferedWriter(new FileWriter("person.txt"));
String s,space=" ";
int num=0;
while(br.ready())
{s=br.readLine();
num++;
bw.writer(String.valueOf(num));
bw.write(space);
bw.write(s);
bw.newLine;
}
bw.close();
}
}
|
import java.io.*;
public class CopyFile
{
public static void main(String args[]) throws Exception
{BufferedReader br=new BufferedReader(new FileReader("shi.txt"));
BufferedWriter bw=new BufferedWriter(new FileWriter("person.txt"));
String s,space=" ";
int num=0;
while(br.ready())
{s=br.readLine();
num++;
bw.write(String.valueOf(num));//bw.writer(String.valueOf(num))
bw.write(space);
bw.write(s);
bw.newLine();//bw.newLine
}
bw.close();
}
}
看注释的地方!(是写错的地方)
public class CopyFile
{
public static void main(String args[]) throws Exception
{BufferedReader br=new BufferedReader(new FileReader("shi.txt"));
BufferedWriter bw=new BufferedWriter(new FileWriter("person.txt"));
String s,space=" ";
int num=0;
while(br.ready())
{s=br.readLine();
num++;
bw.write(String.valueOf(num));//bw.writer(String.valueOf(num))
bw.write(space);
bw.write(s);
bw.newLine();//bw.newLine
}
bw.close();
}
}
看注释的地方!(是写错的地方)