第三行和第五行为什么会报错?
importjava.io.*;publicclassFile{importjava.io.*;publicstaticvoidmain(String[]args){Fi...
import java.io.*;
public class File {
import java.io.*;
public static void main(String[] args){
File f=new File( "D:\\x1.txt");
try {
FileInputStream fis=new FileInputStream(f);
byte []bytes=new byte[1024];
int n=0;
while((n=fis.read(bytes))!=-1){
String s=new String(bytes, 0,n);
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
fis.close();
}
}
} 展开
public class File {
import java.io.*;
public static void main(String[] args){
File f=new File( "D:\\x1.txt");
try {
FileInputStream fis=new FileInputStream(f);
byte []bytes=new byte[1024];
int n=0;
while((n=fis.read(bytes))!=-1){
String s=new String(bytes, 0,n);
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
fis.close();
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询