import java.io.*;
public class file2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
File f= new File("D\\xx\\te.txt") ;
OutputStream out = null ;
try
{
out = new FileOutputStream(f) ;
}
catch(Exception e)
{
System.out.println("asdas");
}
String a =new String("sadasdas") ;
byte[] b = a.getBytes() ;
try
{
out.write(b);
}
catch(Exception e)
{
System.out.println("asdas");
}
try
{
out.close() ;
}
catch(Exception e)
{
System.out.println("asdas");
}
InputStream in = null ;
try
{
in = new FileInputStream(f ) ;
}
catch(Exception e)
{
System.out.println("asdas");
}
byte[] d = new byte[1024] ;
int i= 0 ;
try
{
i = in.read(d) ;
in.close() ;
System.out.println(i);
}
catch(Exception e)
{
System.out.println("asdas");
}
System.out.println(i);
}
}
调试了一下,发现好像所有的try都进catch 了, 感觉上自己应该没错啊,就是输不出我要的结果。
这问题就不该给答案,你都知道它catch到exception了,就不去看一下catch到的是什么东西么?