krishna kumar.s wrote:I have a text file with some row of integers .
I want to transfer this as it is to a double dimension array, i used below programme , i am unable to read line by line and store in seperate rows ,all are stored in one row. Please help.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Other than that, have a look at String.split(). I think you'll find it's exactly what you want
Stefaan Dutry wrote:I don't know if I agree with you on that, although it does return an array, it's an array of Strings, which need to be parsed to integers one by one again.
If you use Scanner again with the line, you can use the hasNextInt() and nextInt() methods to give you integers instead of Strings.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
although I totally agree that num would be better as an ArrayList.
Winston Gutkowski wrote:The advantage of dealing with the input in lines and using String.split() is that you know how big your int[] needs to be when you create it