i have read file function which will read a txt file. after i read it, i put the value to a list. below is sample data:
public void readDisplayClient()
{
DisplayClient dc = null;
try
{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("ClientData.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
String [] values = new String[3];
int counter = 0;
int clientCounter = 0;
//Read File Line By Line
while ((strLine = br.readLine()) != null)
{
// Print the content on the console
String delims = ";";
String[] tokens = strLine.split(delims);
if(counter == 0)//Reading total clients
{
totalClient = Integer.parseInt(tokens[0]);
counter++;
}
else
{
//System.out.println("Test " + counter + " " + tokens.length);
for (int i = 0; i < tokens.length; i++)
{
values[i] = tokens[i];
//System.out.println(tokens[i]);
}
dc = new DisplayClient(clientCounter,values[0],values[1],values[2]);
//dc.printDetails(); // save the connected nodes details to logger txt file.
clientList.add(dc);
clientCounter++;
}
}
//Close the input stream
in.close();
ss.setTotalClient(totalClient);
ss.setClientList(clientList);
//ss.printClientList();
}
catch (Exception e)
{//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
my txt data file will be something like :
2// total 2 conections
0;1;500; // Node 0 connect to Node 1 with 500 kbps
1;2;500 // Node 1 connect to Node 2 with 500 kbps
when node 1 is connected to node 2, it is actually also connect to node 0 as well. Is this able to put it on a hashmap ??
i am a bit confused on it. thanks in advance for help.