| | |
URGENT - Reading from txt file into a 2 dimension array
![]() |
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Solved Threads: 0
:cry: I am trying to create a 2d array that will store the information i hold in the txt file (which is in this format x,y - 45 50
36 47
60 56 etc
then i am supposed to calculate the distance btn x and y and store it in a n-1 matrix(multidimmensional matrix).
To read the information from the file i am using a buffer reader and tokenizer.
So far my attempts have not been successful and i am running out of time - can someone help pls??
N.
36 47
60 56 etc
then i am supposed to calculate the distance btn x and y and store it in a n-1 matrix(multidimmensional matrix).
To read the information from the file i am using a buffer reader and tokenizer.
So far my attempts have not been successful and i am running out of time - can someone help pls??
N.
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Solved Threads: 0
What attempts have you made?
i have tried creating a 2 dimmensional array -
public static void main(String args[])
{
int coords[][];
coords = new int [4][];
for (int i=0; i<4; i++)
{
coords[i] = new int [5];
for (int j=0; j<5; j++)
{
coords[i][j] = 0;
}
What are you having trouble with?
I dont seem to be getting it right and i dont know how to make the array read the coordinates from the text file with the distances:
101 103
107 109
113 127
131 137
139 149
151 157
163 167
173 179
181 191
193 197
This is my first problem. I'm supposed to use a bufferreader and tokenizer to read the file but my java is not that good and i am having problem doing that.
I have an idea of the calculating distance part but i cant go that far without getting the first part right.
Can you help?? Am tearing my hair out :-(
Opening the file? Reading from the file? Calculating the distance? Or setting up the matrix and filling it properly?[/QUOTE]
i have tried creating a 2 dimmensional array -
public static void main(String args[])
{
int coords[][];
coords = new int [4][];
for (int i=0; i<4; i++)
{
coords[i] = new int [5];
for (int j=0; j<5; j++)
{
coords[i][j] = 0;
}
What are you having trouble with?
I dont seem to be getting it right and i dont know how to make the array read the coordinates from the text file with the distances:
101 103
107 109
113 127
131 137
139 149
151 157
163 167
173 179
181 191
193 197
This is my first problem. I'm supposed to use a bufferreader and tokenizer to read the file but my java is not that good and i am having problem doing that.
I have an idea of the calculating distance part but i cant go that far without getting the first part right.
Can you help?? Am tearing my hair out :-(
Opening the file? Reading from the file? Calculating the distance? Or setting up the matrix and filling it properly?[/QUOTE]
![]() |
Similar Threads
- Reading specific numbers in a .txt file and record them in an array (C++)
- Reading a txt file into a swing component (Java)
- reading a txt file into a 2d array (C++)
- Setting an array and reading in a txt file backwards (C++)
- reading txt file into array (C++)
Other Threads in the Java Forum
- Previous Thread: RobustInput
- Next Thread: Sorting Video titles using a ID numbers
| Thread Tools | Search this Thread |
addball android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) button card class classes client code collision columns component constructor crashcourse css database designadrawingapplicationusingjavajslider draw eclipse ee error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image integration intellij j2me java javaarraylist javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia jvm linux loan loop method migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle phone physics plazmic print problem program programming project radio scanner server service set sharepoint smart sms smsspam software sql subclass support swing textfield threads tree trolltech unlimited utility windows






