I have a String datatype called currency type declared and initialized as
private static String currencyType = null;
public static void main(String[] args) throws IOException {
FileWriter fr = new FileWriter("test.txt", true);
BufferedWriter bw = new BufferedWriter(fr);
Scanner sc = new Scanner(System.in);
currencyType = sc.next();
bw.write(currencyType);
bw.close();
}
I give value to this variable by a scanner , sometimes dinar , IQ , $ , Dollar , etc... I created a file just to write the currencyType to the file , the problem is that I just want to give that variable one similar value to all lines of the file , for example when I input $ , anytime I run the program when I want to write the currencyType value to the file it should write $ all of the time , the problem is it doesn't , why ? when I run the program again the currencyType will be null again , I want the variable to get the dataType once and not to be allowed to get back to null again , what is the problem here ?