-1

txtファイルをjarにロードするにはどうすればよいですか? 使えないgetClass().getResource("/DataBase.txt");

public static void readFromFile() throws FileNotFoundException, IOException, ClassNotFoundException{

        FileInputStream fis = new FileInputStream(f);
        ObjectInputStream ois = new ObjectInputStream(fis);
        Authorisation.userMap = (HashMap<String, User>) ois.readObject();
        ois.close();
    }
4

1 に答える 1

0

実際のファイルを読んでいるわけではありません。次を使用してください。

InputStream in = getClass().getResourceAsStream("/DataBase.txt");
ObjectInputStream ios = new ObjectInputStream(in);
于 2013-10-12T03:48:06.237 に答える