Is it at all possible,to convert my number to a string and insert it in the file. After that read it back in as a String and convert it as a integer, so then I can treat it as number. I have tried this using the scanner method and it throws me an exception. Please respond back.
this is what I thought of:
Yes, ofcourse it's possible, and: when you get an exception, please tell us exactly what the exception is and where it occurs - that's valuable information that helps to identify what the cause of the problem is.
An important thing to understand is that Java has two kinds of I/O classes. There are Readers and Writers (the first kind) and InputStreams and OutputStreams (the second kind). Readers and writers are for reading and writing text files. Streams are for reading and writing binary files. Your code is mixing the two up; you're creating a FileWriter but you're not even using it.