Код: Выделить всё
storage/emulated/0/Android/data/ru.iiec.jvdroid/files/newfile WIP .java:40: error: cannot find symbol
FW.close();
^
symbol: variable FW
location: class Main
1 error
< /code>
попытался добавить вторую попытку безрезультатно, и я попытался перемещать вещи и добавить дополнительные полуколоны. Вот мой код. Извините, это беспорядок, это мой первый раз. < /P>
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
Scanner Test = new Scanner(System.in);
String Password;
String TruePassword = "1234";
int I = 0;
File PassAtm = new File ("Attempted Passwords.txt");
System.out.println ("Password?");
//sets loop in motion
do{ Password = Test.nextLine();
try{
try{
//creates and checks to see if new file was created succesfully
BufferedWriter FW = new BufferedWriter (new FileWriter("Attempted Passwords.txt"));
FW.write (Password );
//checks to see if password is correct
if (Password.equals( TruePassword)){
System.out.println ("Nice!");
I = 4;
}
else {
System.out.println ("Dummy.");
I++;
}
}
finally
{
FW.close();
}
}
catch (IOException E)
{
};
}
while (I < 3);
if ( I == 3 )
{System.out.println ("Get outta here, scoundral.");
}
else if (I == 4)
{
System.out.println ("Welcome back, Captain.");
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... -correctly