initialize a number, which is read in from a file, into an array
Hello, it is me again,
i have a new problem... if i wanna read the first number of a file into my java programm as an integer, but it is not working... i tried a lot... so what can i do...
my part of the code is:
private void reading(String fileName)
File file = new File(fileName);
BufferedReader in = new BufferedReader(new FileReader(file));
while((line = in.readLine()) = 0);
int v = line;
for(int i = 0; i = v; i)
n = array[i]
catch (IOException e)
System.out.println("read error: " + e.getMessage());
or sth like this, i am so unsure about it... but makes it sense what i wanna do...
it would be really nice, if anyone could help me
It is not really working how i want to
Hey, it is me again,
i tried the code which i got, but it is not really working as i want to... so i thought i didn't explained clearly my problem.
I have a file which contains number which has to be sorted.
the first number says, how many number i have to sort out. In this case 5. That what i did in my code and called a. Now i have to put the next five numbers, here 6,2,7,3,5 into an array, so that i can sort them out. And there is my problem... i managed to find out the first number, but i don't know how to put the other ones into an array. I wanted to do it in an new method... and with a for-loop like
for(int i = 1; i<=a; i++)
and then sth like
int() field = new int(i);
but it is not really working how i wanted to do it. my first problem is, that i don't know how to get my a into a new method... and then i couldn't do the rest as well...
could anyone help me a bit... that would be really nice