0

I have to write a program that has a log-in window.
I need to check if the username and the password all satisfy what is written in a text file.

the text file which has named as: "pass" contains the following : Admin:icsPro8%

In my validUserName method, I wrote these two lines under the try block to extract what is in the text file "pass" :

try{
   InputFile = new Scanner(new FileInputStream("pass.txt"));
   String name = InputFile.nextLine();
}

But unfortunately, I got this error: "name has private access in java.awt.Component" why this happened ? and how to fix it ?

4

1 回答 1

1

您已经在 try 块中初始化了变量名称,因此您无法在 try 块之外访问它。如果您想全局访问它,请尝试在 try 块之外声明它。

于 2012-05-12T20:45:43.370 回答