[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ascii file to binary format

Posted on 2002-06-27
5
Medium Priority
?
382 Views
Last Modified: 2012-06-22
What is the most elegant way to copy an existing ascii file to a binary format?
0
Comment
Question by:happyloman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 7115543
What do you mean by binary format?
Theoreticly all files are in a binary format.
0
 
LVL 3

Expert Comment

by:yasser_helmy
ID: 7124688
The question is not clear. What do you mean by binary??
0
 

Author Comment

by:happyloman
ID: 7126996
OK, sorry my fault.

I was assuming that there was some kind of file format that I can write a string to a file (e.g. "i pledge allegiance to the flag") whereby the file contains the information but is not human readable, and yet I can programatically open the file and read the string back out.

Is this possible? (without doing some complicated encryptioning)
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 300 total points
ID: 7127029
you can save it in gzip format if you want:

FileOutputStream fos = new FileOutputStream("file");
java.util.zip.GZIPOutputStream zos = new java.util.zip.GZIPOutputStream(fos);

zos.write("some string".getBytes());
zos.flush();
zos.close();

to read it use:
FileInputStream fis = new FileInputStream("file");
java.util.zip.GZIPInputStream zis = new java.util.zip.GZIPInputStream(fis);

BufferedReader reader = new BufferedReader(new InputStreamReader(zis));

String str = reader.readLine();


Also - you ca archive this by wrapping the file stream by ObjectInputStream and ObjectOutputStream

use ObjectOutputStream.writeObject(); for example
0
 
LVL 92

Expert Comment

by:objects
ID: 7128283
There are infinite possibilities.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question