I am having trouble loading data into an array.
This post has been edited by bank217: 04 May 2012 - 04:52 PM




Posted 04 May 2012 - 04:54 PM
int numbers[] = new int[10];
for (int i=0, i < 10, i++){
numbers[i] = 5;
}
for (int i=0, i < 10, i++){
System.out.println(numbers[i];
}
Posted 04 May 2012 - 06:01 PM
File f = new File("text.txt");
BufferedReader b = new BufferedReader(new FileReader(f));
ArrayList<String> list = new ArrayList<String>();
String s = "";
while(b.ready())
s += b.readLine();
//after this just use s.substring & s.index of to incrementally move through your string
//while storing each substring in your array
//i recommend using ArrayList and then using .toArray()
Posted 04 May 2012 - 07:16 PM
File f = new File("text.txt");
Scanner scan = new Scanner(new File("myFile.txt"));
ArrayList<String> list = new ArrayList<String>();
while(scan.hasNextLine())
list.add(scan.nextLine());
Posted 04 May 2012 - 11:43 PM
pbl, on 04 May 2012 - 07:16 PM, said:
File f = new File("text.txt");
Scanner scan = new Scanner(new File("myFile.txt"));
ArrayList<String> list = new ArrayList<String>();
while(scan.hasNextLine())
list.add(scan.nextLine());
Posted 05 May 2012 - 11:17 AM
File f = new File("text.txt");
Scanner scan = new Scanner(new File("myFile.txt"));
ArrayList<String> list = new ArrayList<String>();
while(scan.hasNextLine()) {
String[] token = scan.nextLine().split(",");
for(String str : token)
list.add(str);
}
File f = new File("text.txt");
Scanner scan = new Scanner(new File("myFile.txt"));
ArrayList<String[]> list = new ArrayList<String[]>();
while(scan.hasNextLine())
list.add(scan.nextLine().split(",");
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
