胃粘膜脱落怎么引起的:看看这个java

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 07:11:14
无法运行啊
import java.io.*;
public class BuildFile
{

public static void main(String[] args)
{

System.out.println("Now you will build a txt file,yourself.");
System.out.println("please enter one name for the txt file.");
String nameOne=Pyc.getMyString();
boolean i=testWay(nameOne,"txt");
while(i==false)
{
System.out.println("try again!");
nameOne=Pyc.getMyString();
i=testWay(nameOne,"txt");
}
System.out.println("you do it very well!");
PrintWriter input=null;
try{
input=new PrintWriter(new FileOutputStream(nameOne));
System.out.println("enter the value for "+nameOne+" ,one value per line,"
+"and ending with a negetive number");
try{
int k=0;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
k=Integer.parseInt(in.readLine().trim());
while(k>=0)
{
input.println(Integer.toString(k));
k=Integer.parseInt(in.readLine().trim());

}
}
catch(IOException e)
{
System.out.println(e.getMessage());
System.exit(0);
}
input.close();
}
catch(FileNotFoundException e)
{
System.out.println("Error opening the file "+nameOne);
System.exit(0);
}
catch(IOException e)
{
System.out.println("you make a mistake in entering.");
System.exit(0);
}

System.out.println();
System.out.println("Now you will build a dat file,yourself.");
System.out.println("please enter one name for the dat file.");
String nametwo=Pyc.getMyString();
i=testWay(nametwo,"dat");
while(i==false)
{
System.out.println("try again!");
nametwo=Pyc.getMyString();
i=testWay(nametwo,"dat");
}
System.out.println("you do it very well!");
ObjectOutputStream put=null;
try{
put=new ObjectOutputStream(new FileOutputStream(nametwo));
System.out.println("enter the value for "+nametwo+" ,one value per line,"
+"and ending with a negetive number");
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));;
try{
int k2=0;
k2=Integer.parseInt(in.readLine().trim());
while(k2>=0){
put.writeUTF(Integer.toString(k2));
k2=Integer.parseInt(in.readLine().trim());
}
}
catch(IOException e)
{
System.out.println(e.getMessage());
System.exit(0);
}
put.close();
}
catch(FileNotFoundException e)
{
System.out.println("Error opening the file "+nametwo);
System.exit(0);
}
catch(IOException e)
{
System.out.println(e.getMessage());
System.exit(0);
}
}
private static boolean testWay(String a,String b)
{
if (a.lastIndexOf("."+b)==-1)
return false;
else
return true;

}
}

String nameOne=Pyc.getMyString();
Pyc是什么?
哦。。
我看到了
我运行了,可以运行
在命令行下运行的
运行结果:
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\>F:\Java\jre1.5.0_06\bin\java.exe BuildFile
Now you will build a txt file,yourself.
please enter one name for the txt file.
123.txt
you do it very well!
Error opening the file 123.txt

C:\>

是不是运行的结果不对?
你说明白一些

米有编译器。。
Java...

太有“钱途”米“前途”啊。。