hyi i am currently working on a project at the moment its a little program that reads in a file and is then stored as as array but the loop will only read 7 items of the array how can i extended so it reads more ps the stuff on the file is details of endangered species i,e there name, count, etc so if you could please have a look at the code at make some modification i would be very greatfull
package myprojects.testarray;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class Testarray {
public static void main(
String args[]) {
// A simple example of how to read in animal descriptions and plonk
// them in an array.
// Remember that count should really be an integer and a bit of conversion will have
// to occur.
// Also note that this example reads in 7 animals, but your version should detect
// the end of the file (i.e. use a different sort of loop).
String name[ ] = new String[1000];
String count[] = new String[1000];
String species[] = new String[1000];
String country[] = new String[1000];
try {
File inFile = new File("F:\\animals.dat");
// Create a file stream, wrapping the file
FileReader fileReader = new FileReader(inFile);
// Create a second wrapper,
BufferedReader bufReader = new BufferedReader(fileReader);
// Read in the first line...
String s;
// Read in 7 animals (how can this be improved?)
for (int i=0; i<7; i++) {
name[i] = bufReader.readLine();
count[i] = bufReader.readLine();
species[i] = bufReader.readLine();
country[i] = bufReader.readLine();
System.out.println("Name "+i+" is "+name[i]);
System.out.println("Count "+i+" is "+count[i]);
System.out.println("species "+i+" is "+species[i]);
System.out.println("Found in "+i+" is "+country[i]);
}
System.out.println("Starting Testarray...");
Testarray mainFrame = new Testarray();
}
catch (IOException e) {
System.out.println("IOException "+e);
}
}
}