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!

How to Write A Binary File.

807601Jun 22 2008 — edited Jun 23 2008
I am creating a program which will save data but i want this data to be encrypted/or unreadable.

I have created a simple console application which reads users input changes it into bytes and saves it to a file.
But its still saving it as readable text? any ideas?
			Scanner in = new Scanner(System.in);
			FileOutputStream fos;
			
			try
			{
				fos= new FileOutputStream(new File("data.txt"));
							
				System.out.print("Enter String: ");		
				String msg = in.nextLine();
				byte[] wordInBytes = msg.getBytes();
				fos.write(wordInBytes);
				fos.flush();
				fos.close();
				
			}
			catch(Exception e)
			{
				System.out.println(e);
			}
Thank you for any help,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 21 2008
Added on Jun 22 2008
4 comments
221 views