Well, with this, we will need to use FileWriter. We can overwrite the original file with the new text we want.
FileWriter out = new FileWriter("hello.txt");
out.write(//new value of x);
out.close();
By the way, both FileWriter and Reader constructors throw IOException, so you have to handle it. (try, catch)