出力ストリーム ファイルの作成に問題があります。
OutputStream output = new FileOutputStream(username + ".txt");
byte buffer[] = data.getBytes();
output.write(buffer);
output.close();
別の方法を作成するまで、うまくいきました:
public void actionPerformed (ActionEvent e) //When a button is clicked
{
if (e.getSource() == encrBtn)
{
menu.setVisible(false);
createProfile();
menu.setVisible(true);
}
else
{
if (e.getSource() == decrBtn)
{
menu.setVisible(false);
viewProfile();
menu.setVisible(true);
}
else
{
if (e.getSource() == exitBtn)
{
JOptionPane.showMessageDialog(null, "Goodbye!");
System.exit(0);
}
}
}
}
以前は、例外を呼び出す各メソッドの先頭に throws Exception を配置しました。
createprofile();
メソッド (出力ストリームがある場所)。しかし今、私は得る
ProfileEncryption_2.java:54: error: actionPerformed(ActionEvent) in ProfileEncryption_2 cannot implement actionPerformed(ActionEvent) in ActionListener
public void actionPerformed (ActionEvent e) throws Exception //When a button is clicked
^
overridden method does not throw Exception
以前は、例外をスローする別の方法があるかどうか疑問に思っていました: ActionListener で actionPerformed(ActionEvent) を実装できません 。これについて複数の言い回しをグーグル検索しましたが、これを行う方法がわかりました...見つけたものも機能しませんでした。