public class Operle 
{
FileInputStream input = null;
File f1 = new File("D:"+File.separator +"Person.txt");// 此处报  标记";"上语法有错,在此标记之后应为 {
try
{
input=new FileInputStream(f1);
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
input.close();
}
}     //此处报   语法错误,请将"}"插入完整ClassBody中
为什么会报这样的错,什么原因?? 高手指点

解决方案 »

  1.   

    先整理下,LZ排版没做好public class Operle  
    {
        FileInputStream input = null;
        File f1 = new File("D:"+File.separator +"Person.txt");
        // 此处报 标记";"上语法有错,在此标记之后应为 {
        try
        {
            input = new FileInputStream(f1);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            input.close();
        }
    } //此处报 语法错误,请将"}"插入完整ClassBody中
      

  2.   

    先整理下,LZ排版没做好public class Operle  
    {
        FileInputStream input = null;
        File f1 = new File("D:"+File.separator +"Person.txt");
        // 此处报 标记";"上语法有错,在此标记之后应为 {
        try
        {
            input = new FileInputStream(f1);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            input.close();
        }
    } //此处报 语法错误,请将"}"插入完整ClassBody中
    ]
      

  3.   

    很明显,LZ把代码直接写到类里面去了,而不是置于某个方法中!
    LZ先理解下类是什么,它的结构是什么?
      

  4.   

    好象file文件的路径也不能这样写哟。
      

  5.   

    将你所有的代码加载public static void main中试试
      

  6.   

    File f1 = new File("D:"+File.separator +"Person.txt");
    你直接写成
    File f1 = new File("D:\\\\Person.txt");
    不可以么?
      

  7.   


    public class Operle {
    public static void main(String[] args) throws IOException {
    FileInputStream input = null;
    File f1 = new File("D:"+File.separator +"Person.txt);
    try
    {
    input=new FileInputStream(f1);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    finally
    {
    input.close();
    }
    }}
    这样没有报错·