java文件编程 总是显示40'{' expected} catch (IOException e);错误

来源:百度知道 编辑:UC知道 时间:2024/06/05 00:13:13
import java.io.*;
import java.util.Date;

public class FileInfo{

public static File getFileForFilename(String filename)
throws IOException{
File fi=new File(filename);
if(!fi.exists)
throw new IOException("File not found");
if(!fi.isFile())
throw new IOException("Not a file");
return fi;
}

public static void showLabel(String label,String s){
System.out.print(label);
System.out.println(s);
}

public static void showInformation(File fi){
showLabel("Path=",fi.getPath());
showLabel("Filename=",fi.getName());
showLabel("Length=",new Long(fi.length()).toString());
showLabel("Readable=", new Boolean(fi.canRead()).toString());
showLable("Writable=",new Boolean(fi.canWrite()).toString

楼主这个有n多错误啊.前面的我帮你改好了
public static File getFileForFilename(String filename) throws IOException {
File fi = new File(filename);
if (!fi.exists())
throw new IOException("File not found");
if (!fi.isFile())
throw new IOException("Not a file");
return fi;
}

public static void showLabel(String label, String s) {
System.out.print(label);
System.out.println(s);
}

public static void showInformation(File fi) {
showLabel("Path=", fi.getPath());
showLabel("Filename=", fi.getName());
showLabel("Length=", new Long(fi.length()).toString());
showLabel("Readable=", new Boolean(fi.canRead()).toString());
showLabel("Writable=", new Boolean(fi.canWrite()).toString());
showLabel("Modified=", new Date(fi.lastModified()).toString());
}

后面的main函数内也有错误.readLine不能单独用的.要想得到键