> For a project, we need to read a text file, that contains an integer
> value on every line. We would like to store the integer values in an
> array (the first integer being stored in arrayname[1]).
What do you intend doing with element arrayname[0]?
>...Does anybody have an idea how to write such a program?
Yes.
> We are grateful for any help we get!
Feel free to drop by once you formulate a specific question.
But please review your course notes, hack out some code[1],
and read the PhySci FAQ[2] carefully before replying.
[1] Have you done the HelloWorld program?
[2] <http://www.physci.org/codes/javafaq.jsp>
>..Thank you very much in advance.
You're very much welcome.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Here is a quick hack. The lines are read into an arraylist which is
then copied to an array. The first integer is stored in arr[0] i.e.
integer k is stored in arr[k-1]. If thats not what you want, you can
fix it easily.
BufferedReader in = new BufferedReader(new
FileReader("data.txt")) ;
String line = "" ;
ArrayList nums = new ArrayList() ;
while((line = in.readLine())!=null){
int num ;
try{
num = Integer.parseInt(line) ;
nums.add(new Integer(num));
}catch(NumberFormatException e){}
}
int[] arr = new int[nums.size()] ;
for(int i = nums.size() ; --i>=0 ;){
arr[i] = ((Integer)nums.get(i)).intValue() ;
}

Signature
Fahd Shariff
"Let the code do the talking... "