任何人都可以向我解释(指向正确的文档)如何将HTML页面嵌入到Java对话框中?非常感谢你们.
我有以下方法获取direcory名称:
private List<String> getListOfDirectories(String rootDirectoryPath) {
List<String> listOfDirectories = new ArrayList<>();
File directory = new File(rootDirectoryPath);
File[] listOfFiles = directory.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isDirectory()) {
listOfDirectories.add(listOfFiles[i].getName());
}
}
return listOfDirectories;
}
Run Code Online (Sandbox Code Playgroud)
我暂时存储(不确定是否存储是正确的术语)列表中的这些目录名称.如果有50000个目录名,那么List是正确的选择吗?它是否具有内存效率,是否可以处理50000或更多字符串?
编辑:我正在开发一个应用程序,在本地目录中搜索html文件并解析这些html文件.
我试图用C#编写一个简单的客户端/服务器应用程序.以下是发送给我的客户端的示例服务器回复:
reply {20}<entry name="test"/>
Run Code Online (Sandbox Code Playgroud)
其中{20}表示完整回复包含的字符数.在下面我写的代码中,我如何使用这个数字来循环和读取所有字符?
TcpClient tcpClient = new TcpClient(host, port);
NetworkStream networkStream = tcpClient.GetStream();
...
// Server Reply
if (networkStream.CanRead)
{
// Buffer to store the response bytes.
byte[] readBuffer = new byte[tcpClient.ReceiveBufferSize];
// String that will contain full server reply
StringBuilder fullServerReply = new StringBuilder();
int numberOfBytesRead = 0;
do
{
numberOfBytesRead = networkStream.Read(readBuffer, 0, readBuffer.Length);
fullServerReply.AppendFormat("{0}", Encoding.UTF8.GetString(readBuffer, 0, tcpClient.ReceiveBufferSize));
} while (networkStream.DataAvailable);
}
Run Code Online (Sandbox Code Playgroud) 在类的方法中,我更新相同的标签两次.第一次,它显示要等待的用户消息,但第二次向用户显示已完成的消息.类似于以下内容:
MyClass{
myMethod(){
jLabel.setText("Please wait...");
//does calculation
jLabel.setText("Completed successfully!");
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,我看到的只是"已成功完成"消息.JLabel更新速度太快了吗?我该如何控制它?我尝试使用以下但没有运气:(
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
jLabel.setText("Please wait...");
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个带有两个JButton的jTextField(向上箭头和向下箭头按钮).单击向上箭头按钮,文本字段中的数值增加1(++),单击向下箭头按钮,文本字段中的数值减1( - ).
我想知道的是如何在按下按钮时自动"滚动/更改"值?
谢谢