I am reading a .Csv file and am having problems trying to get the information I want, set up the way I want.
Here is where my problem comes in:
String[] info = beanInfo.split("," , 3);
for (String str : info) {
ip = info[0];
hostname = info[1];
ping = info[2];
}
Basically I am wanting to set column 1 to my ip information, column 2 to my hostname information, and column 3 to my ping information.
Whenever I attempt to print out any of the following strings ip, hostname, or ping; it duplicates the information its printing out by 3.
So basically if I do:
System.out.pringln(ip);
It will print out:
192.168.0.0
192.168.0.0
192.168.0.0
Instead of just:
192.168.0.0
If I print str, then it prints the information off exactly the way I want it just not by the columns I want it to be recognized with. This is what it would look like if I print out str:
192.168.0.0
myHostname
2 m/s
192.168.0.1
myHostname2
2 m/s
192.168.0.2
myHostname3
1 m/s
and so on...
So did I misunderstand the point of the 'number of fields' portion after my delimiter when splitting the string?