Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading file issues - unknown character gets inserted

801487Dec 1 2008 — edited Dec 2 2008
Hi Friends,
I am trying to read some characters from a file but it's adding some unknown characters to it. The source file has this line:
0??0
I use this code to read the characters from the source file:
            File inputfile = new File("myfile.txt");
	    FileInputStream from = new FileInputStream(inputfile);
	    byte [] buffer = new byte[4096];
	    int charsread;
	    while((charsread = from.read(buffer)) != -1);
	    from.close();
	    String text = new String(buffer);
	    text = text.trim();
	    String publickey = text.toLowerCase();
But the output has an extra '?' symbol in it i.e.
0?0
Basicallty, the file i am trying to read is a rsa public key and I am not sure if it has to do something with encoding. Can someone please help?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2008
Added on Dec 1 2008
16 comments
674 views