1 Replies - 92 Views - Last Post: 08 October 2012 - 05:06 PM Rate Topic: -----

#1 kpc147  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-October 12

I need the read data directly to combox in 2d array

Posted 08 October 2012 - 05:02 PM

import java.io.*;
import java.util.*;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;


public class Location{ String location;
String id;
public static void main(String args[]) {

ArrayList<Location> locationlist = new ArrayList<Location>(50);

int i,i2,i3;
String[] theword = null;

try {

FileReader fr = new FileReader("myfile.txt");
BufferedReader br = new BufferedReader(fr);
String line = "";

while ((line = br.readLine()) != null) {
String[] theline = line.split(" | ");

for (i = 0; i < theline.length; i++) {
theword = theline[i].split(" ");
Location locations = new Location();
for (i2 = 0; i2 < theword.length; i2++) {

locations.location = theword[i2];

//locations.id = theword[i2+1];
locationlist.add(locations);
System.out.println("The content of arraylist is: " + locations.location);



}
} //System.out.println("The content of arraylist is: " + locations.location);
//System.out.println("The content of arraylist is: " + locations.id);


}//System.out.println("The content of arraylist is: " + locationlist);
}
catch (IOException ex) {
System.out.println("Could not read from file");
}
}
}

Is This A Good Question/Topic? 0
  • +

Replies To: I need the read data directly to combox in 2d array

#2 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 559
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: I need the read data directly to combox in 2d array

Posted 08 October 2012 - 05:06 PM

Go read the rules of the forum, then you might receive a bit of help. As things stand, your breaking atleast 5 rules.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1