I need help creating a Binary file that displays in Hex and readable text! I have already completed the gui part I need help converting to Binary.

Here is what is required:

16 Byte values displayed as 2 digit hex values separated by 2 spaces, then a separator | and then the text representation of these same characters

This is what I have already, I think the problem is that I have read file instead of InputFile:

public void actionPerformed(ActionEvent evt)
{
JFileChooser chooser = new JFileChooser();
int state = chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();

if(file != null && state == JFileChooser.APPROVE_OPTION)
{
JOptionPane.showMessageDialog(null, "Opening: " + file.getPath());
StringBuffer content = new StringBuffer();
BufferedReader reader = null;
try
{
reader = new BufferedReader(new FileReader(file));
String text = null;
while ((text = reader.readLine()) != null)
{
content.append(text).append(System.getProperty("line.separator"));
}
reader.close();
}

catch (IOException e)
{
e.printStackTrace();
}

resultArea.append("Integer.toHexString((int) charToConvert");

}

Any help is appreciated.
Thanks

What's the problem?
I don't see where are you attempting to print the contents as hex. You should probably not use readLine(). Use any variant of read() instead it returns a single char (or specified number which can be 8 or 16 or 32 depending on how you want to show).
Once you have that it should be easy enough to print each char as hex.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.