gedit uses UTF encoding. Therefore, if we store binary data in the file (like through DataOutputStream's writeInt() or writeByte(), etc.), gedit would rightly complain, but if we write something through the writeUTF() function, then gedit should be able to open it as the data is written is UTF which it recognizes. But it does not. It complains :

gedit has not been able to detect a character encoding. Please check if you are not trying to open a binary file.

The following was the code :

class first
	public static void main(String aa[])
		FileOutputStream n=new FileOutputStream("anjana.txt");
		DataOutputStream k=new DataOutputStream(n);
		FileInputStream a=new FileInputStream("anjana.txt");
		DataInputStream b=new DataInputStream(a);
		catch (IOException e){System.out.println("error : "+e);}

The javadoc of DataOutputStream.writeUTF() method says the following
"First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow"

anjana.txt would have a short (2 bytes of data) followed by the UTF String. gedit would NOT know how to interpret the first 2 bytes. IMHO using DataOutputStream to a text file and opening it using gedit will NOT work. Use a FileWriter instead of DataOutputStream.

Thanks. It definitely doesn't use UTF.