나는 txt 파일을 읽을 파일 읽기 기능이 있습니다. 내가 그것을 읽은 후에, 저는 그 값을 목록에 넣었습니다.readfile 및지도에지도
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());
}
}
내 TXT 데이터 파일이있을 것입니다 뭔가 같은 : 아래의 샘플 데이터이며, 1 500
2 // 총 2 conections
0; // 노드 0 500 kbps의
1 노드 (1)에 연결하고 2; 500 // 노드 1 2 500 kbps의 노드 (1) 노드 (2)에 접속 될 때 가
, 실제로도 연결된다
를 노드에 연결 노드 0도 마찬가지입니다. 이 해시 맵에 넣을 수 있습니까 ??나는 약간 혼란 스럽다. 도와 주셔서 미리 감사드립니다.
파일의 모양, 데이터의 의미 및 방향을 그래프로 표시하는 방법에 대한 예를 넣을 수 있습니까? 우리는 당신이하려고하는 것을 정말로 알지 못합니다. – jbx
안녕하세요, 저는 데이터 txt 파일을 삭제했습니다. 내가 위에 읽을 샘플 txt 파일을 넣었습니다. 덕분에 – Eric