Having trouble with reading hex from an input file - please help

Hi, I have a txt file with rows of hex, and I need to read each line and add it to an int array. So far I have:
BufferedReader fileIn = new BufferedReader(new FileReader("memory.txt"));
                int count = 0 ;
                String temp = fileIn.readLine();
                int file_in = Integer.parseInt(temp) ;
                while(temp!=null) {
                     data[count] = file_in;
                     temp = fileIn.readLine();
                     file_in = Integer.parseInt(temp,16);// Integer.parseInt() ;
                     count++ ; /* increment counter */
                } memory.txt:
4004000
4008000
3FDF4018
4108200
3C104001
FFFFFFE8
4010C6C0
FFFFFFE8
94000000The above code crashes on the third input (my guess is becuase there are letters in and it can't parseInt letters.
I think I need to parse it into an array of chars instead, however I don't know how to get from the string (temp) to the char array.
can anyone help?

ok turns out it's just a null pointer exception on the data[count] line, becuase I've only initialised the first two slots of data. i didn't see it before becase it was just throwing an error and i never printed it out.
here's how I've defined data:
in the class
int[] data;just before the code to input the file data:
for ( int i = 0; i < length; i++ )       
                data [ i ] = 0;thinking this shoudl go through all the array and initialise it. but it gives a NullPointerException on the data=0; line.
any ideas?
Edited by: rudeboymcc on Feb 6, 2008 10:50 PM
Edited by: rudeboymcc on Feb 6, 2008 10:51 PM

Similar Messages

  • Having trouble with flash and linking to Sliding panels - PLEASE help

    Having trouble with Sliding panels and flash. Otherwise everything works fine but when I'm trying to implement the link
    <a href="#" onclick="sp1.showPanel('panel1'); return false;">Panel1</a>
    to a flash button I get confused. I have tried following
    on (press) {
    getURL("javascript:sp1.showPanel('panel1');");
    and it did not work. What would you suggest? I am desperate. Please help me! Any suggestions are highly appreciated!!!!

    Thanks for your answer!
    I have tried both sp1.ShowPanel('panel1'); and window.sp1.ShowPanel('panel1'); they both give blank window with [object]
    I have found a solution that works in other browsers, but not in IE. Well basicly it works, but after a few clicks IE freezes.
    on (press) {
    getURL("javascript:sp1.showPanel('panel1'); void(0);");
    Would you happen to have a solution other than that? I believe that the void(0); causes the IE to freeze.

  • HT2589 having trouble with redeeming iTunes card??? please help.

    I need help please. Wow this is asking so many question that aren't getting me any where.. I can't redeem my itunes card..

    Take a picture instead of typing in the code

  • Having trouble with my  email from google

    Having trouble with my email from gmail, both on my iPhone and on my iMac. It keeps asking to validate my password and e en after that it won't work. Does anyone know what to do?

    Hey Florian Fangohr,
    Thanks for the question. I understand you are experiencing issues with Mail in OS X Mavericks. Base on the symptoms you provided, the following article may help to resolve your issue:
    Mail (Mountain Lion): If your password is not saved
    http://support.apple.com/kb/PH11775
    If you click “Save password” in a dialog in Mail but still have to enter your password, there are a couple of things you can try.
    - Open Keychain Access, and then locate and delete the mail account password item.
    While in Keychain Access, you can also choose Keychain Access > Keychain First Aid to verify and repair keychain settings.
    - Open Disk Utility, and then select the volume (for your hard disk or disks) in the list of disks and volumes. Click First Aid and then click Verify Disk. If necessary, click Repair Disk. Then send yourself a test message.
    Note: The same steps apply for OS X Mavericks
    Thanks,
    Matt M.

  • I am having trouble with downloading videos from my Sony HDR-XR160 video camera. iMovie doesnt open up when i connect the camcorder. any suggesions?

    i am having trouble with downloading videos from my Sony HDR-XR160 video camera. iMovie doesnt open up when i connect the camcorder. any suggesions?

    Looking up your camera online, I found it is capable of 1920 x 1080 Full HD 60p Recording. It's the 60p (60 frames per second Progressive) that's the problem I think. iMovie '11 will do 60i (Interlaced). You might need to convert it from the format the camera currently uses into another format to get it into iMovie. Read more about it on this link here: How to import 60p footage From that message thread comes the recommendation to use ClipWrap to convert the camera's video clips now that they are in 60p:
    Tom Wolsky
    Re: How to import 60p footage 
    Aug 17, 2011 12:40 PM (in response to ptburnett68)
    Use ClipWrap to rewrap to QuickTime. Import the files. Edit in either 59.94 or 29.97. The latter if you want to use the high frame rate for slomo

  • I'm having trouble with video imported from my camera memory card.

    I'm having trouble with video imported from my camera memory card.The video breaks up and pixelizes when it's directly imported from the memory card. That makes the video useless. Why does this happen? It doesn't do that in any other video editing software. Thanks for the help.

    More info please:
    Type of camera?
    Was the card formatted in the camera doing the shooting?
    Type of files the camera is set to record?
    Al

  • Hi i am having trouble downloading a flashplayer on my samsung tablet please help

    Hi i have been having trouble downloading flashplyer to my samsung tablet 10" please help me.

    Your best option for using Flash on Android these days is to use the Puffin browser:
    Puffin Web Browser - The fastest mobile browser with Flash support over cloud on iPad, iPhone and Android.

  • I am new to Mac and am having trouble with uploading images from my pictures folder to Facebook and other share sites- some of my images are accessible while others are seemingly locked....

    I am new to Mac and am having trouble up loafing images from my pictures folder to photography sites and Facebook. Some of the saved images are accessible, while others are not, ( they are light colored and cannot be uploaded) I am not saving them any differently.

    Hi Robodisko,
    Thanks for your prompt reply...... 
    I often proof my work in preview then edit images in photoshop and rename from there.  The dsc images are renamed to correlate the name of the class etc.  i.e. dcs_001 is saved as the file name required 7A.jpeg etc.
    The file names are required to correlate what is what and so on..........

  • I have an Ipod Touch (4th Gen) and I am having troubles with my downloads from purchasing music from the Ipod. On my downloads icon in the Itunes Store (on Ipod) there is a symbol of how many songs I still have waiting to download, but they wont download.

    I have been having troubles with this for months and am extremly tired of not being able to download my songs. I bought these songs off of Itunes as well, so I really hope i can retrieve them. I do not know where to find a personal apple support person yet, does anyone know where to find one on the website?

    See these previous discussions:
    Waiting applications: Apple Support Communities
    Downloading apps stuck on waiting...: Apple Support Communities

  • I am having trouble with my iphone 3GS,contact list andphone icon, Help Please

    I am having trouble with my iphone 3GS, when i select my contact list or the phone icon, they open with a white screen and close almost immidiately meaning that i am unable to call or save contacts however i can recieve calls. Help Me Please

    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).  Has any of this been tried?

  • Having trouble with creating objects from instances created with ClassLoade

    Hi.
    I'm having a bit of trouble with casting an instance of an object from a custom ClassLoader. Don't worry - the code isn't for anything sinister - it's for one of those life simulation thingies, but I want to make it modular so people can write their own 'viruses' which compete for survival. You know the score.
    Anyway. I've got the beginnings of my main class, which seems to load the class data for all 'virus' classes in a folder called 'strains'. There is a abstract class called AbstractVirus which declares the method calls for how the viruses should behave and to get textual descriptions, etc. AbstractVirus is to be subclassed to create working virus classes and these are what my main class is trying to load instances of.
    Unfortuantely, I can't cast the instances into AbstractVirus objects. The error I've been getting is 'ClassCastException' which I presume is something to do with the fact that my ClassLoader and the Bootstrap ClassLoader aren't seeing eye-to-eye with the class types. Can anyone help? This line of programming is really new to me.
    My code for the main class is below:
    /* LifeSim.java */
    public class LifeSim {
      public LifeSim() {
        /* Get a list of all classes in the 'strains' directory and store non-
         * abstract classes in an array. */
        Class virusClasses[] = null;
        try {
          /* Get a reference to the file folder 'strains' and make sure I can read
           * from it. */
          java.io.File modulesFolder = new java.io.File("strains");
          if (!modulesFolder.isDirectory() || !modulesFolder.canRead()) {
         System.out.println("Failed to find accessible 'strains' folder");
         System.exit(-1);
          /* Get a list of all the class files in the folder. */
          String virusFiles[] = modulesFolder.list(new ClassFileFilter());
          if (virusFiles.length == 0) {
         System.out.println("No virus strains in 'strains' folder");
         System.exit(-1);
          /* Create an array of class objects to store my Virus classes. Ignore the
           * abstract class as I cannot instantiate objects directly from it.*/
          virusClasses = new Class[virusFiles.length];
          VirusClassLoader classLoader = new VirusClassLoader();
          int j = 0;
          for (int i = 0; i < virusFiles.length; i++) {
         String virusName = "strains/" + virusFiles;
         Class tempClass = classLoader.loadClass(virusName);
         if (tempClass.getName().compareToIgnoreCase("strains.AbstractVirus") != 0) {
         virusClasses[j++] = tempClass;
    } catch (ClassNotFoundException ncfe) {
    System.out.println("Failed to access virus class files.");
    ncfe.printStackTrace();
    System.exit(-1);
    /* TEST CODE: Create an instance of the first virus and print its class
    * name and print details taken from methods defined in the AbstractVirus
    * class. */
    if (virusClasses.length > 0) {
    try {
         // Print the class name
         System.out.println(virusClasses[0].getName());
         Object o = virusClasses[0].newInstance();
         strains.AbstractVirus av = (strains.AbstractVirus) o;
         // Print the virus name and it's description
         System.out.println(av.getQualifiedName());
         System.out.println(av.getDescription());
    } catch (InstantiationException ie) { ie.printStackTrace(); }
         catch (IllegalAccessException iae) { iae.printStackTrace(); }
    public static void main(String args[]) {
    new LifeSim();
    class ClassFileFilter implements java.io.FilenameFilter {
    public boolean accept(java.io.File fileFolder, String fileName) {
    if (_fileName.indexOf(".class") > 0) return true;
    return false;
    class VirusClassLoader extends ClassLoader {
    private String legalClassName = null;
    public VirusClassLoader() {
    super(VirusClassLoader.class.getClassLoader());
    public byte[] findClassData(String filename) {
    try {
    java.io.File sourcefile = new java.io.File(filename);
    legalClassName = "strains." + sourcefile.getName().substring(0,sourcefile.getName().indexOf("."));
    java.io.FileInputStream fis = new java.io.FileInputStream(sourcefile);
    byte classbytes[] = new byte[fis.available()];
    fis.read(classbytes);
    fis.close();
    return classbytes;
    } catch (java.io.IOException ioex) {
    return null;
    public Class findClass(String classname) throws ClassNotFoundException {
    byte classbytes[] = findClassData(classname);
    if (classbytes == null) throw new ClassNotFoundException();
    else {
    return defineClass(legalClassName, classbytes, 0, classbytes.length);
    Thank you in advance
    Morgan

    Two things:
    I think your custom ClassLoader isn't delegating. In general a ClassLoader should begin by asking it's parent ClassLoader to get a class, and only if the parent loader fails get it itself. AFAIKS you could do what you're trying to do more easilly with URLClassLoader.
    Second, beware that a java source file can, and often does, generate more than one class file. Ignore any class files whose names contain a $ character. It's possible you are loading an internal class which doesn't extend your abstract class.

  • TS3899 How do I fix my email account on my iphone 5? I have been having problems with my hotmail on my phone. Please help.

    At first I deleted my account as suggested by the support article and instaled my hotmail account again.
    Now I don't have access to my email anymore.
    Please help.

    No, hotmail is having problems:
    http://bostinno.streetwise.co/2013/08/15/hotmail-outage-hotmail-is-down-for-user s-still-photos/
    http://www.engadget.com/2013/08/14/outlook-outage/
    http://www.infoworld.com/d/applications/microsofts-skydrive-outlookcom-are-down- some-users-224940
    http://mashable.com/2013/08/14/outlook-down/
    http://techcrunch.com/2013/08/14/microsoft-acknowledges-outlook-com-messenger-sk ydrive-outages/

  • HT1473 I recently had to restore my laptop back to factory settings and lost my itunes music. I have imported all my cds again but i have some music on my ipad mini and am having problems importing this back into my itunes file. please help as this is dri

    I have recently reset my laptop to factory settings and whilst doing so have lost my music files. I have uploaded my cds but am having trouble moving music from my ipad mini back to music file or itunes.

    iTunes sync is one way from iTunes library to an iOS device.
    You will need third party software such as TouchCopy to transfer from iOS to your computer.

  • I'm having troubles with reinstalling lion from Recovery HD

    Hello everybody. Please keep in mind that I'm not english, so I'll probably do some grammar errors.
    Here there's my problem:
    I decided to reinstall Mac OS X Lion, on my macbook pro 15" (late 2010). Everything worked well, I just wanted to clean everything and start over again.
    I started the computer from Lion Recovery HD, which is, as we all know, in a separate partition.
    I followed the instructions written in the documentation: I initialized the Hard Drive with a HFS+ file system from the utility disk, then, I clicked on "Reinstall Mac Os X".
    After choosing the right HD and writing the username and password for the mac app store, i got an error: my account is allowed only in the Italian store (I'm from Italy, but I'm temporarily in the USA. I also wrongly forgot my Snow Leopard DVD in Italy )
    Anyways, after clicking OK and writing ID and PWD again, the download of the OS finally starts (First problem solved?)
    After more then 15 hours downloading, I came home but it didn't change a lot: the computer was still on recovery hd (i think it restarted by itself?), the download was finished, but it didn't install the OS, nor I could boot from the main HD. If I try to click "Reinstall Mac Os X" again, it would ask for my id and pwd again, and start the 15 hours download another time, as nothing had happened.
    By the way, i checked the HD from the utility disk, and about 4 GB are used in the HD, while before the download I had initialized it, so I think Lion was downloaded there. I repeat, I can't startup from the main HD, since it's not available when I turn the computer on and press option.
    Sorry for the long message, but I tried to give you the most informations I could provide. If you need other informations, tell me.
    Thank you very much for the help, by know I'm stucked on a $2000 machine that has only Safari on it, with the scrolling that is in the wrong way
    Alefus

    Not sure what happened, but I think your best bet it to try again.

  • Still having trouble with reading text file into array

    Hi, This is from another post, I have tried one of the solutions that were provided, but got the following error at runtime:
    C:\j24work>java Test7
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException
    at java.lang.StringBuffer.deleteCharAt(StringBuffer.java:681)
    at Test7.main(Test7.java:26)
    My code is attached. My text file reads as follows:
    7 5.5 15 5.35 30 6.5
    The first , third and fifth numbers should ultimately be int values representing the term of a mortgage. The second, fourth and sixth numbers ultimately need to be doubles representing the rate on a mortgage. Do I need a 2d array??
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.text.*;
    public class Test7 {
        public static void main(String[] args) throws Exception {
            String line        = null;
            int count   = 0;
            StringBuffer Term  = new StringBuffer();
            StringBuffer Rate  = new StringBuffer();
            BufferedReader input = new BufferedReader (new FileReader ("MortgageValues.txt"));
            while ((line = input.readLine()) != null) {
                if(count%2 == 0) Term.append(line).append(",");
                else        Rate.append(line).append(",");
                count++;
            Term.deleteCharAt(Term.length() -1);
            Rate.deleteCharAt(Rate.length() -1);
            System.out.println("Term>>>" +Term);
            System.out.println("Rate>>>" +Rate);
           // input.close ();
        }

    Okay, modify the code as below:
    import java.io.*;
    import java.util.*;
    public class Test7 {
        public static void main(String[] args) throws Exception {
            String line             = null;
            StringTokenizer strTok  = null;
            int count          = 0;
            StringBuffer term  = new StringBuffer();
            StringBuffer rate  = new StringBuffer();
            BufferedReader input = new BufferedReader (new FileReader ("MortgageValues.txt"));
            while ((line = input.readLine()) != null) {
                strTok = new StringTokenizer(line);
                while(strTok.hasMoreTokens()) {
                    if(count%2 == 0)    term.append(strTok.nextToken()).append(",");
                    else                rate.append(strTok.nextToken()).append(",");
                    count++;
            term.deleteCharAt(term.length() -1);
            rate.deleteCharAt(rate.length() -1);
            System.out.println("term>>>" +term);
            System.out.println("rate>>>" +rate);
           input.close ();
    }Cheers!
    ***Annie***

Maybe you are looking for

  • Sender File adapter stops polling

    Hi All, We have a strange issue. A sender File (NFS) communication channel which was working fine, suddenly stops polling. The cache, is upto date. There are no errors in the channel monitoring. In fact the polling logs are being recorded in the RWB

  • Ploblem for plug-in in Adobe Reader X

    We have developed plug-in for Adobe Reader (Adobe Acrobat) in windows OS a couple of years ago. Before  Adobe Reader X it works well.  But it doesn't work correctly in the Adobe Reader X. we find some issues following : 1. the API ::GetActiveObject 

  • What is the risk, and how to detect, Trojan infection with Flashback/Flashfake? (PowerMac G5 OS X 10.5.8)

    What is the risk, and how to detect, Trojan infection with Flashback/Flashfake? (PowerMac G5 OS X 10.5.8)

  • CS4 Design Premium MAC...Installed But No Flash Showing Up

    I have installed Adobe CS4 Design Premium MAC and when I go to the list of programs, Flash Professional does not show up on the list.  Does anyone know why?  What could be causing that to happen?  Are there any known issues with this?  Does anyone kn

  • Do I still need a mac mini AND a MacBook?

    Hmm..my MacBook will have a duo core processor instead of the single core of the mini....it can output a digital signal to my 32" LCD TV/Monitor, it has the same Front Row software and the wireless remote, it has a built in iSight camera, it can oper