【发布时间】:2014-03-17 02:47:06
【问题描述】:
对于这个 java 程序,我必须读入三个字符串值;来自文本文件的 SSN、姓氏和名字,以创建 1000 个节点。然后,稍后创建一个跳过列表。但是,我很难(或忘记)如何读取 SSN、姓氏和名字字符串变量的这些值。文本文件是这样的,我意识到字符中断将是';'然后按到下一行。
510421600;雪莱;摩根
790701850;霍尔顿;何塞
932371897;海因斯;娜奥米
714797789;昆克尔;迪伦
878566780;格里沙姆;艾莉
到目前为止,这是我的 Node 类的内容。
package list;
import java.io.File;
/** * Represents the nodes and list of SSNs * @author Adam Taylor * @version 1.1 */
public class Node
{
/**
* The last name of the person
*/
public String lastName;
/**
* The first name of the person
*/
public String firstName;
/**
* The SSN of the person
*/
public String SSN;
/**
* The head of the node
*/
public Node head;
/**
* The tail of the node
*/
public Node tail;
/**
* The node pointers
*/
public Node Link1, Link2, Link3, Link4;
/**
* The NodeObject
*/
public Node next;
public Node(int i, int j, int k)
{
File file = new File("Database.txt");
}
public String getSSN()
{
return "";
}
public String toString()
{
return "SSN:" + SSN + " Last Name: " + lastName + " First Name: " + firstName;
}
}
【问题讨论】:
标签: java string file linked-list