I need to read the following txt.file with Scanner
in java. The problem with this file is that there is a lot of information I don't need. The only things I need are the parameter(s) and the values of those parameters ( as an example, I need String n and int 5, String p and double 0.5, String lambda and double 0.3 ... ) the problem seems to be in the empty lines. I added the code I made, but if I run this, the second line of a distribution is never read.
What am I doing wrong?
txt-file as input:
distributie lengte klasse 1 naam verdeling parameter(s) value of parameter
n 5
p 0.5
distributie lengte klasse 2 naam verdeling parameter(s) value of parameter
lambda 0.3
distributie incidentie klasse 1 naam verdeling parameter(s) value of parameter
d 1
distributie incidentie klasse 2 naam verdeling parameter(s) value of parameter
n 8
p 0.1
distributie servertijd klasse 1 naam verdeling parameter(s) value of parameter
d 1
distributie servertijd klasse 2 naam verdeling parameter(s) value of parameter
p 0.3
aantal pakketten te verwerken 2000000
code
for(int a = 0; a< 6; ++a){
inputStream.nextLine();
System.out.print("\n"+inputStream.next());
System.out.print("\n"+inputStream.next());
String line = "";
if (!(line = inputStream.nextLine()).isEmpty())
{
System.out.print("\n"+inputStream.next());
System.out.print("\n"+inputStream.next());
}
else
{
}
inputStream.nextLine();
}}