Coding Global Background
Coding Global

Java BufferedWriter problem

Archived 3 years ago
3 messages
0 members
Created 3 years ago
Updated 3 years ago
Open in Discord
T
terrylamarr
I'm trying to make a data saving system and it reads in the data perfectly fine but only if I delete the writeData method. It seems as though writeData is being called somehow and writing null to the file even though I have not done se anywhere in my code.
I am only called readData.
public static void readData() {
        try {
            String[] line = in.readLine().split(",");
            System.out.println(line);
            count = Integer.parseInt(line[0]);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    public static void writeData() {
        try {
            out.write(count);
            out.flush();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

Replies (3)