Partheban Udayakumar wrote:I am trying to write a date in a file. I want to write it because I need to see the last time the program has been run.
I am working on Net beans in Ubuntu. If I convert it to an integer and write it to a file, some Chinese letters are displayed in the file.
You have to remember that OS commands that print the file (such as the "type" or "cat" commands) and text editors (which are used to examine such files) are designed for text files. When you write binary data such as integers and long, it is no longer a text file. It is now a binary file. The integer is saved correctly, and you can read it back too. However, it is not a text file, and hence, can not be examined by the tools designed for text files.
If you want to write integers or longs, so that it can be read by a text file based tool, you will need to convert the value into a string first. Try using the toString() method of the Integer class. Or the DecimalFormat class. Or since it is a date, the SimpleDateFormat Class.
Henry