有人可以告诉我这段代码中的令牌是什么吗?我最近刚刚在 Java 中发现了标记,并试图了解为什么要使用它们。我以为令牌被用作断点,但在这里它几乎看起来像是用来限制
private String printResult()
{
StringBuilder result = new StringBuilder();
String swimType=null;
String length=null;
String width=null;
String depth=null;
String volume=null;
String radius=null;
String pnlName = null;
try {
File resultFile = new File("Report.txt");
Scanner resultScanner = new Scanner(resultFile);
while(resultScanner.hasNext())
{
StringTokenizer strToken = new StringTokenizer(resultScanner.nextLine(), ":");
if(strToken.hasMoreTokens())
{
pnlName = strToken.nextToken();
swimType = strToken.nextToken();
if("Box".equalsIgnoreCase(swimType))
{
length = strToken.nextToken();
width = strToken.nextToken();
depth = strToken.nextToken();
volume = strToken.nextToken();
result.append(createResultStr(swimType, length, width, depth, volume));
}
else
{
radius = strToken.nextToken();
depth = strToken.nextToken();
volume = strToken.nextToken();
result.append(createResultStr(swimType, radius, depth, volume));
}
}
}