Java Swing GUI to Open File and Display Text

  • Status Closed
  • Budget N/A
  • Total Bids 24

Project Description

Require a Java Swing GUI program that opens a file as a binary stream and then displays the values of each byte in Hex and as readable text.

The program should have a reasonable GUI including the title “Binary File Viewer”

The program should display the name of the file being viewed.

The program should use a Swing TextArea to display the file using the specified format below. This should allow the user to scroll back and forth through the entire file.

The program should include a New button that allows the user to enter the name of the file to view. Use the java file picker dialog for this. Be sure to code it so that it will recover from errors and not simply terminate the program.

The program should include a Quit button.

Assume that your program will read the entire file into memory and create the display content within the textArea.

Make sure that the program closes any opened files especially when the user exits the program.

Required Display format:

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. For the text representation, use a period or dot for non-printing characters (like a carriage return) and just display the printable ones.

Here is an example of what you should display:

AD EF 00 10 46 56 23 50 AD EF 00 10 46 56 23 50 |..aBntefg.?>..

AD EF 00 10 46 56 23 50 AD EF 00 10 46 56 23 50 |..aBntefg.?>..

AD EF 00 10 46 56 23 50 AD EF 00 10 46 56 23 50 |..aBntefg.?>..

AD EF 00 10 46 56 23 50 AD EF 00 10 46 56 23 50 |..aBntefg.?>..

Display at least 16 lines of output, unless the file you are viewing is shorter than that.

To be clear, there are 16 characters to the right of the | separator which correspond directly to the 16 hex byte codes on the left. So, looking at the example above the first byte has the value of AD and the first character to the left of the | separator is the printable character that has that same code or is a period if that value is not printable. (I did not bother to look up the codes for the example so it only shows the format, not the actual text characters for the hex bytes values but your program will.)

Note that the program should be exactly formatted like this. Each Hex byte should be 2 hex digits with two spaces between each byte. Do not put spaces between the text representation characters on the right side of the separator.


You will want to use the JFileChooser Swing component to implement the open file dialog for the file viewer. There are some issues when the user enters the forward slash \ as the directory separator because java will interpret it as the escape character. You can fix this by searching though the file string and either replacing the forward slash with a backslash / or inserting an extra forward slash \.

Insure that each byte has two digits. This means that you may have to append the leading zero for a value like 0A = 10 in dec.

The program has to compile of course and I require the source code. Thank you.

The code should be adequately commented. If you utilize shared code, please reference credit to the author, in the comments.

Get free quotes for a project like this
Awarded to:
Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online