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 :
import java.io.*;
class first
{
public static void main(String aa[])
{
try{
FileOutputStream n=new FileOutputStream("anjana.txt");
DataOutputStream k=new DataOutputStream(n);
k.writeUTF("2");
//k.writeUTF("3");
FileInputStream a=new FileInputStream("anjana.txt");
DataInputStream b=new DataInputStream(a);
System.out.println(b.readUTF());
}
catch (IOException e){System.out.println("error : "+e);}
}
}