Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-04-2007, 10:05 AM
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
Problems with arrays
I have to read a large text file into an array and sort each of the columns. The text file is set out so that it is in lines for each patient, and then between each piece of information about that patient, there is a certain amount of whitespace. I was thinking of using a 2D array to put it all in, but the problem is I can't work out how to split each line up so that each piece of info is in its own spot in the array.

Basically, the text file looks like this:

Code:
1 name 15 285 806 180 2 name2 50 850 710 107 3 name3 13 105 185 160
Thanks!
Marcus
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-04-2007, 10:08 AM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
Have you written any code? In any case, you should consider using StringTokenizer for the purpose of splitting entries etc.

Here is a good example.

Greetings.

Albert
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-04-2007, 10:10 AM
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
Oh, I'm definitely not expecting anyone to do any work for me. I was just totally stuck as to how to split the file, and I kind of assumed that was my starting place.

All I've done so far is read the file in with BufferedReader:

Code:
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Sorter { public static void main(String[] args) { double[][]dataarray; try { BufferedReader input = new BufferedReader(new FileReader("file.txt")); } catch(IOException e){ System.out.println("Unable to read file"); } } }
Some of the data pieces in the text file are doubles, some are ints. However, there are a few where there's an NA for a value, which makes it a string, so I've just realised I probably won't be able to handle this in a 2D array.

Thanks
Marcus
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some problems with arrays and loops BHCluster New To Java 3 04-16-2008 02:24 PM
Arrays bunbun New To Java 1 04-09-2008 04:24 AM
[SOLVED] Problems with arrays hayjk New To Java 3 04-07-2008 07:52 PM
2D-Arrays kbyrne New To Java 1 02-08-2008 12:08 AM
arrays help Warren New To Java 6 11-23-2007 09:23 PM


All times are GMT +3. The time now is 11:01 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org