File I/O question

Hi, guys
I'm making my program to read txt file and store the data (number) into 2D array.
My txt file looks like this:
* Test date: 05/25/05
* Test Temperature: 35F
~Tester: Bob Wilson
Current[mA] voltage[mV] Power[mW]
-0.0007 -0.0061 0.0006
-0.0002 0.0203 0.0066
0 0.2317 0.008
0.0017 0.5957 0.0008
I want to make array with only double values. Some body gave me an idea that let my program to read each line, tokenize it, and then call Double.parseDouble on the first token. If it throws an exception, you just skip it and move on, else you process it But I don't know where to start..and how to implement it.
Does anybody have good example source code I can take a look at?
Thanks a lot,
private void readTheFile()
// Open the file
int row=0;
int col=0;
openFile();
data[10][3];
FileReader file = new FileReader(fileName);
fileInput = new BufferedReader(file);
System.out.println("Read the file");
// Loop through file incrementing counter
try {
String line = fileInput.readLine();
while (line != null)
StringTokenizer st=new StringTokenizer(line);
while(st.hasMoreTokens())
String token=st.nextToken();
data[row][col]=token;
System.out.print(data[row][col]+ " ");
col++;}
System.out.println();
row++;
col=0;
line = fileInput.readLine();
closeFile();
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error reading File", "Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile();
System.exit(1);
}

Thanks for the quick reply.
Is there any way to check out the first token only, and if it's not double type skip to tne next line? In my source code, it seems to be checking every single token in the line and then move on the the next line. This is not the way I want.
Thanks in advance again.
try {
                String line = fileInput.readLine();
                while (line != null)
                    StringTokenizer st=new StringTokenizer(line);
                    while(st.hasMoreTokens())
                        String token=st.nextToken();
                        try
                            double temp=Double.parseDouble(token);
                            data[row][col]=token;
                            System.out.print(data[row][col]+ " ");
                            col++;
                        catch(NumberFormatException ex)
                  System.out.println();
                  row++;
                  col=0;
                  line = fileInput.readLine();
                }

Similar Messages

  • How do I get rid of the flashing file with a question mark in it?

    I wanted to start clean on my MacBook Pro osx 10.9.4. So I did the command r and erased what I thought was the right one. I restarted my computer and did the command r again and what came up was internet recovery. It can't find my internet because it's WEP and I don't know to change it to wpa. So I restarted my computer again and I didn't do the command r but just let it load itself to see what would happen and all I get is a flashing file with a question mark. I don't know what to do. Someone please help me.

    Do you get this display?
    If so, you have to select an Internet connection.  Do not expect quick response time in this mode.  All activities in this mode will be lengthy.
    Ciao.

  • I need to reinstall my operating system for 10.5 after seeing a file folder and question mark flashing on my start up screen. Can anyone help me with this?

    I need to reinstall my operating system for 10.5 after seeing a file folder and question mark flashing on my start up screen. Can anyone help me with this?

    Hello,
    That means it can find the Hard Drive, or can't find the things needed for booting.
    See if DU even sees it.
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)

  • HT4718 I have nothing on my Mcintosh HD after trying to install Mavericks. I did save a recovery copy of files however this was also lost. All I now have is a file with a question mark with nothing else happening. What should I do?

    Apple recently sent a message asking me if I would like to upgrade to Mavericks which was free. I considered installing after saving a copy of my HD to a WD external drive. I proceeded with the instalation however when it was time to reboot the programme the computer displayed a message that it could not process the request due to errors with the hard drive. The computer then requested that i save a copy and the verify disk and repair disk which i followed and the computer would not repair due to an error. At which pioint I did some research and was told by the IMac to push shift when it starts to enter disk utility and repair the Mcintosh HD. I did as asked however the computer would still not install with Mavericks.
    So after many attempts of trying to start over, I was prompted to erase the Mcintosh HD and reboot using the saved copy. At this point all data was lost and all that is left on my computer is a file with a question mark with no way of restoring the HD drive. Could anyone help please?

    It sounds like your HD may have died.
    If you could answer a few questions it may help figure out what you should do next:
    What OS did you have on your computer before you tried to upgrade to mavericks?
    Did your computer originally come with installer disks?

  • I have a white intel i mac and when i boot up a file with a question mark shows up

    i installed wnow leopard and then attempted to use boot camp to install windows (thats a whole other story though) after i got windows on it and then got it back to the mac side i found i could not get back to the windows side so i attemted to delete the windows partition and recreate my full mac partition (thats not as easy as i thought it would be, anyway i ended up with a partition that said it was the alloted mac partition space and another one, that apperead smaller in disk utility, that said it was 160 gb (my total disk size) while i was trying to fix that i hit the power strip switch with my foot and the whole thing shut down when it booted back up the only thing on the screen was a file with a question mark on it, i think it is just booting from the misconfigured parition but im not sure ive tried inserting my snow leopard and xp system disks but it doesnt seem to be booting from them.

    At startup hold down the Option/Alt key t bring up the One time Boot Selection, Startup Manager, screen and then select the OS X install DVD. Give it about 30+ second for the DVD drive to read and display the OS X install DVD.
    Then use Disk Utility to Repartition the drive as one partition and then try installing OS X.
    Could be you simply killed that drive with all the new installs of OS X and then Windows and then using Disk Utility to erase the Windows partition. If that is the case you'll need to replace the drive before you'll be able to reinstall any OS on it.
    In any event Never use Disk Utility to erase a Windows install. Use the Boot Camp Assistant a second tim to Remove Windows and the partition it is installed on.

  • MacBook Pro flashes file folder with question mark and startup manager will not run

    My son's MacBook Pro won't boot (gets the flashing file folder with question mark).  When I try to open startup manager (holding "option" key during boot does not do it).  Other posts suggest inserting the install disk, but I am pretty sure that for Lion, there was no disk, it was just off the website through the App Store.  Any further suggestions?

    Reinstalling Lion/Mountain Lion Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • Hi I installed a new hard drive in my Mac mini osx lion an when I turn it on I get a flashing file with a question mark. I tried holding command and R keys when turning it on but the recovery fails to work. Does any one know how I can get it to recover?

    Hi I installed a new hard drive in my Mac mini osx lion an when I turn it on I get a flashing file with a question mark. I tried holding command and R keys when turning it on but the recovery fails to work. I can hold the option key at start up and choose my network, then Internet recovery shows up with an arrow pointing up. When I click on the arrow Internet recovery fails and all I get is a globe with a triangle on it with an exclamation mark on it, and under that it says
    apple.com/support
          -6002F
    Does any one know how I can fix this without a recovery disc? Thanks

    I just want to add to this, in case someone else searches for this error on Apple Support (google doesnt cover apple support.. how clever is that?)
    I had the same error. And i had a Computer that had worked, with a SSD drive and 16GB upgrade done by the owner himself.
    I tried swapping with a Mechinal Harddrive, no luck.
    Kept the Mechanical drive in, and tried with some other Ram, it worked..
    So for me this error and after reading the other responses can be boiled down to a Harddrive problem or Ram issue.
    It was Ram for me..

  • Hi can anyone help with a mac that had magnet put on it. I turned it on and then off but a white screen appears with a file with a question mark on it?

    Hi can anyone help with a mac that had magnet put on it. I turned it on and then off but a white screen appears with a file with a question mark on it?

    File icon with ? mark on it means it can't read from the hard drive. The hard drive is now wiped or bad. If just wiped then you will need to reinstall your operating system, OS X. If bad you will need to replace the drive.
    Start with booting the computer from the OS X install DVD that came with your system. If the Mac came with Lion Pre-Installed then you use the Lion internet recovery system to reinstall (Hold down Command+r keys or Command+Option+r keys to boot the computer from over the internet to the Lion recovery HD system).
    Good Luck.

  • I can't restart my mac , I get a file with a question mark? Help

    Need help, what to do when I cannot restart my mac. I get a file with a question mark?

    That indicates that your Mac is unable to find a system to boot from
    This is usually caused be either a corrupt system file, corrupt ot dead disk drive
    Allan

  • Getting white screen with file folder and question mark on it...help

    My MacBook Pro starts up and only shows a white screen with a file folder with question mark on it.  I have not had problems prior to this.  Help!,

    That means that no valid system could be found to boot from.  What might have caused that is hard to say, but try referring to this document:
    http://support.apple.com/kb/ts1440
    Note that if you are using Mac OS X 10.7 (Lion), you don't start up from your install disk.  Hold down command-R at startup instead.

  • I powered up my macbook and there is a file folder with question mark on the screen flashing.  What does that mean?

    Powered up Mac book and screen showing file folder with question mark flashing? 

    A flashing question mark appears when you start your Mac
    Hope that solves your issue.

  • Restarted and received a blinking file folder with question mark image.

    I left my computer sitting while I was working on homework long enough for the screen saver to come on (I'm not sure exactly how long it was). Earlier in the day, I had to force quit safari and then later it unexpectedly quit several times. While my computer was sitting, it looked like it does when it restarts. I waited until it started to come back up, and instead of coming up to the desktop, it came up with a blinking file folder and question mark. I had not done anything unusual with it, and had not tried to restore it. My dad was working on trying to fix it, and inserted the OS X disk. When the options came up, in the repair feature, the disk could not locate my harddrive. I was wondering if anyone else had encountered this problem, and if so how it was resolved. If anyone had any tips or ideas of things I could try that would be great. I can't really get it to an apple store soon, and I'm a student so my computer is very important to me. Thanks.

    Mornin' John,
    I also have an OWC external firewire drive that I tried to install OSX Tiger to but was told that I could not install OSX Tiger on the external drive.
    What Format is that Drive? GUID/MacOS Extended? It should work if the right format.
    Is there any way to run Disk Warrior from the external hard drive ... to try and rectify this issue, or at least get my data off the dead drive (if it is so)?
    From the external only if you can get OSX installed.
    What version is it? Do you mot have the CD?
    or from my PowerBook G4
    Possibly, with the MaBook in FW Target Mode
    http://docs.info.apple.com/article.html?artnum=58583
    If DiskWarrior can't fix it, you might try Data Rescue II...
    http://www.alsoft.com/DiskWarrior/
    http://www.prosofteng.com/products/data_rescue.php
    (Has a Free Demo to see if it could or not, but you'll need another drive to recover to).

  • I've got a 15" white macbook which I bought about 2 years ago. It froze the other day and wouldn't respond so I shut it down. When I turn it on now it comes up with a flashing file with a question mark on it. How can I fix it?

    I've got a 15" white macbook which I bought about 2 years ago. It froze the other day and wouldn't respond so I shut it down. When I turn it on now it comes up with a flashing file with a question mark on it. How can I fix it? I've tried a few things i've seen online but the futhest ive got is to put the start up disk in when you makes it go to a grey screen with an apple logo and the spinning wheel which then stops spinning. Can anybody help?

    That folder with the question mark icon means that the MacBook can't find the boot directory. That can either mean it can't find the hard drive or the Operating System data on the hard drive is somehow corrupted.
    Put your install DVD into the optical drive and reboot. As soon as you hear the boot chime, hold down the "c" key on your keyboard (or the Option key until the Install Disk shows up). That will force your MacBook to boot from the install DVD in the optical drive.
    When it does start up, you'll see a panel asking you to choose your language. Just press the Return key on your keyboard once.It will then present you with an Installation window. Completely ignore this window and click on Utilities in the top menu and scroll down to Disk Utility and click it. When it comes up is your Hard Drive in the list on the left?
    If it is then click on the Mac OS partition of your hard drive in the left handlist. Then select the First Aid Tab and run Repair Disk. The Repair Disk button won't be available until you've clicked on the Mac OS partition on your hard drive. If that repairs any problems run it again until the green OK appears and then run Repair Permissions.
    If your hard drive isn’t recognized in Disk Utility then your hard drive is probably dead.

  • Grey screen and file icon with question mark appearing at startup on old model macbook

    We own  a very old model macbook and the startup screen appears as grey and an icon appears in the shape of a file with a question mark in the middle and the startup does not proceed from there. Any help would be much appreciated.
    Thanks,
    Athula

    Some things to check/try in no particular order:
    https://support.apple.com/kb/TS1440
    http://support.apple.com/kb/ts2570
    https://discussions.apple.com/docs/DOC-5282

  • Database Toolkit Sub query Syntax and file path expectation question.

    I need some assistance from those of you smarter than I. 
    I have two database files (not two tables in the same database file) one represents information delivered from an external interface, and the other is used by the internal interface associated with the processing half of my application.  Data is received (i.e. fields are populated)  from the external interface to one database file and that data is then copied to another database file where the information will be processed by the internal interface. This is being done because I am worried about  file access issues that might occur if two different interfaces (external & internal) try to access the same file at the same time (without dealing with semaphores). I am not too worried about the sanctity of the data since each record supplied from the external interface should not effect any of the data being used by the internal interface.  So the first question is , am I being to primitive in my thinking assuming that I would run into file access issues if I were to just use two tables in the same database file for the same purpose ?
    My second question is related to my current implementation where I have two separate database files representing the external and internal interface data. Currently when a new set of data is entered into the External Interface Database file, an alert is issued, and another task copies the data from that file into Internal Interface Database, then the data is deleted from the External Interface Database file. My question is related to the syntax that I am using to provide the described functionality. I am currently using a INSERT with a subquery to the External Interface Database file i.e. INSERT INTO InternalDB FROM  ExternalDB.ExternalTable WHERE Order =  '06306049'; .
    My question is when I run this query with both database files in same directory I get an error stating that the ODBC driver can not find the ExternalDB.ExternalTable in the Parent Directory of the subdirectory where the files are actually located. The system DSN is set up correctly for the ExternalDB, and if I move it to the parent directory the query works correctly, my question is why would I have to put the two database files in seperate directories for this to work and is there a way to avoid this ?
    Thanks..
    Brad W

    Thanks for responding Brian -
    The message I get is Error Code -2147467259
    Conn Execute.vi->InsertIntoFrom.vi<ERR>Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC Microsoft Access Driver] Could not find file 'C:\Project\APDSS\DataBase\ExternalInterface.mdb'. in Conn Execute.vi->InsertIntoFrom.vi
    When my query looks like
    INSERT INTO InternalInterface SELECT Field1, Field2 FROM ExternalInterface.ExternalTable WHERE Id = '065649-101-750';

  • White screen with flashing file icon with question mark mean

    What does this mean.   We are getting a white screen with flashing file icon with question mark inside the file. 

    It almost certainly means it can't find a bootable volume (one with OS X on it).
    Which means most likely you will have to find your original system installation DVD and install it. Then you should figure out what caused the problem.
    Read this to diagnose it before resorting to reinstalling the OS:
    http://support.apple.com/kb/TS1440
    Excerpt:
    Additional steps
    If your Mac still starts to a flashing question mark, follow the steps below. If any step resolves the issue, you don't need to continue to the next one.
    Select your Mac OS X startup disk with Startup Manager by restarting and holding the Option key. After your Mac starts up, restart again to verify that the flashing question mark does not appear.
    If the issue persists, insert your Mac OS X installation disc. Be sure to either use the disc that came with your Mac, or, if you installed a later Mac OS X version from disc, use the newer disc.
    MacBook Air note: On a MacBook Air, there are two options for starting up from Mac OS X media: Either connect a MacBook Air SuperDrive to the MacBook Air via the USB port and restart the computer, holding down the C key during startup, or use Remote Install Mac OS X to startup from a system software DVD that's located on a partner computer. Once started up from Mac OS X media, skip to step 3.
    Restart the computer, then hold the C key during startup.
    From the Utilities menu, choose Disk Utility. Don't click Continue.
    Select your Mac OS X disk (named "Macintosh HD" by default) in the left side of the Disk Utility window.
    Click the First Aid tab.
    Click Repair Disk to verify and repair any issues with your Mac OS X startup disk.
    After repairing the disk, try to start up normally.
    Important: If Disk Utility finds issues it cannot repair, you may need to back up as much of your data as possible (or use Time Machine to back up to a different disk), then erase the disk and reinstall Mac OS X. You should back up important files and data before erasing a drive. Erasing deletes everything on the hard disk (including things on your desktop). Also, you can install Mac OS X onto an external disk, start from the external disk, and use Migration Assistant to transfer items from your usual internal Mac OS X startup disk to the external disk, then erase the internal disk and reinstall Mac OS X.
    If the issue persists, and Disk Utility didn't find any irreparable issues, quit Disk Utility, quit the Installer, select your disk when prompted, and restart.
    If the issue continues, reset PRAM. Note: After resetting PRAM, if the computer starts up normally, reselect the startup disk in the Startup Disk preferences.
    If none of these steps resolve the issue, start up from the Mac OS X Installation disc and reinstall Mac OS X.

Maybe you are looking for