62,623
社区成员
发帖
与我相关
我的任务
分享
import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
public class main
{
public static void main(String[] args) throws IOException
,FileNotFoundException
{
StringTokenizer tokenizer;
String fileAddress; //the address of the file
String addressInput; //the file name entered by the user
String s; //the token
int lineNo; //the number of lines in the text
int i;
int counter; //the number of all the words in the text
// TokenCounter tokenCounterA;
addressInput = JOptionPane.showInputDialog("Enter the file name:");
// while loop starts, prompt the user to input the file name, and the whole
// program starts.. when the program ends, prompt the user to enter a new file
// name or enter nothing to terminate the program
while(addressInput.length() > 0)
{
fileAddress = "h:\\" + addressInput;
BufferedReader inFile =
new BufferedReader(new FileReader(fileAddress));
tokenizer = new StringTokenizer(inFile.readLine());
s = tokenizer.nextToken();
lineNo = 1;
counter = 0;
while (s.length() > 0)
{
counter++;
System.out.println("Line" + lineNo + ": " + s );
if(tokenizer.hasMoreTokens())
s = tokenizer.nextToken();
else
{
if(inFile.readLine() != null)
{
tokenizer = new StringTokenizer(inFile.readLine());
lineNo++;
}
else
s = "";
}
}
System.out.println("All words:" + counter);
//prompt the user to enter another file name
addressInput = JOptionPane.showInputDialog("Enter the file name:");
}//while loop ends
//terminate the program
System.exit(0);
}
}
| 和 | 等标签构建行、列与表头结构,形成语义清晰的数据展示框架。在DOM中,每个表格元素均可被JavaScript访问与操作,实现动态内容更新。通过原生JS可获取表格节点并调用其方法,为后续增删改查功能奠定基础。是原生 JavaScript 中用于创建任意 HTML 元素节点的核心方法。相较于和这类专用于表格的操作 API,提供了更强的灵活性和控制力,尤其适用于需要插入包含输入框、下拉菜单、按钮或其他复杂控件的表格行场景。 |
|---|