Noob question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Noob question

  1. #1
    Join Date
    Oct 2005
    Posts
    2

    Noob question

    I am new to Java - I have read the first few chapters of the Objects First in BlueJ book.

    I want to create code that will read a file and display its content in hex format. I will then devlop this code as my studying progresses.

    I was wondering if anybody could help me get started - I have looked the FileReader classes in the Java.IO package. I was also wondering if I could iterate through the file and put individual characters into an Arraylist. Could this be done?

    Thanks in advance

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    255
    Yes, this is possible. FileReader.ready() indicates if the file could be read further (which could be used to check for each iteration) and FileReader.read() could read a character or a set of characters (with a buffer array specified). If you want to read line by line, use BufferedReader instead.
    Happiness is good health and a bad memory.

  3. #3
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    If the file is not ASCII text, you will need to use a class that reads bytes vs characters.
    See InputStream and its subclasses such as FileInputStream. The read method will read bytes into an array which may be easier to convert to hex than characters.
    bytes can be cast to int and then processed by the Integer class method that can create a hexString.

  4. #4
    Join Date
    Oct 2005
    Posts
    2
    Right - I have managed to get my file into a byte array. They appear as decimal representations of the ASCII characters. How do I now manipulate this array to output the binary, hex or even the ASCII characters equivalents of these decimal values?

    Thanx in advance

Similar Threads

  1. A noob with a question...
    By Goggy in forum VB Classic
    Replies: 4
    Last Post: 05-04-2005, 02:52 PM
  2. Display one record at a time!
    By ASP learner in forum ASP.NET
    Replies: 5
    Last Post: 10-08-2002, 08:17 PM
  3. question on best programming option
    By James in forum .NET
    Replies: 2
    Last Post: 03-28-2002, 08:14 AM
  4. VB,STORED PROC, COM, DTC QUESTION?
    By melvin ng in forum VB Classic
    Replies: 1
    Last Post: 11-10-2000, 04:46 AM
  5. Performance question
    By John in forum VB Classic
    Replies: 2
    Last Post: 04-05-2000, 10:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center