⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readsequentialfile.java

📁 一个飞机调度员模拟训练程序,可以添加跑道数量,控制飞机飞行的速度.默认的密码可以在AtcSystem类里面修改,其中内置了三个用户名.这套系统是我和几个国外同学合力开发的,希望对大家有帮助
💻 JAVA
字号:

/**
 * Write a description of class ReadSequentialFile here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */


import java.io.*;

public class ReadSequentialFile
{
    // instance variables - replace the example below with your own
    private ObjectInputStream input;
    private String fileName;

    /**
     * Constructor for objects of class ReadSequentialFile
     */
    public ReadSequentialFile(String fileName)
    {
        // initialise instance variables
        this.fileName = fileName;
    }

    /**
     * An example of a method - replace this comment with your own
     * 
     * @param  y   a sample parameter for a method
     * @return     the sum of x and y 
     */
    public void openFile()
    {
        try //opening file
        {
            input = new ObjectInputStream(new FileInputStream("H:\\" + getFileName() + ".usr"));
        } // end try
        catch (IOException ioException)
        {
            System.err.println("Error Opening File.");
        } // end catch
        
    } // opening file
    
    
    public void readATCRecords()
    {
        User user;

        
        try // read from file
        {
            while (true)
            {
                
                user = (User)input.readObject();
                User testUser = new User(user.getUserName(), user.getPassWord(), user.isAdmin(), user.getResults());

            } // while
        }
        catch(EOFException endOfFileException)
        {
            return;
        }
        catch(ClassNotFoundException classNotFoundException)
        {
            System.err.println("Unable to create object.");
        }
        catch(IOException ioException)
        {
            System.err.println("Error during read from file");
        }
        
    } // end reading
    
    public String getFileName()
    {
        return fileName;
    }
     
    public void closeFile()
    {
        try // close file and exit
        {
            if (input != null)
                input.close();
        }
        catch(IOException ioException)
        {
            System.err.println("Error closing file.");
            System.exit(1);
        }
    }
        
            
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -