Skip to Main Content

Java Programming

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!

Writing special character to a text file

807605Jul 12 2007 — edited Jul 13 2007
Hi,

I have a text will with encrypted data which show as special character in the file and plain text. If I read and write to another file I get only question marks for the special characters. But this only occurs when I run it from a jar file from the command prompt.

If I run the code from a IDE it works correctly. So I am really hosed on this one. I run the JAR file on Solaris with does not works. I also run the file in Eclipse IDE on Solaris and it works. This also happens if I try to append to the file. The data in the file looks like

w383 ~I~Y~D~A��~U~G
w384 ~D| �~X�~U~\~Y
cm89 ~Q����~\~A�

After I run from the jar file it looks like:

w383 ~I~Y~D~A��~U~G
w384 ~D| �~X�~U~\~Y
cm89 ~Q����~\~A�
w385 ???????

Here is the code I uses.
		String nameFile = "/usr/files/passfile";
		String addTxt = userId + " " + pCode + "\n";
		boolean status = false;
		try {
			BufferedWriter out = new BufferedWriter(new FileWriter(nameFile,
					true));
			out.write(addTxt);
			out.close();
			status = true;
			logger.info("\n\nAdded user:  " + userId + " to password file: "
					+ nameFile + "\n\n");
		} catch (IOException e) {

			// e.printStackTrace();
			logger.info("\n\n"+e.getMessage());
		}
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2007
Added on Jul 12 2007
4 comments
1,240 views