我正在运行一个比较程序,并且它在一分钟内进行直接的"字符串到字符串"比较,如果它们是完全匹配,则输出它们是匹配的.
好吧,我希望增加一个允许"相似性"的附加功能......
例如:
String em1 = "52494646";
String em2 = "52400646";
if (em1.equals(em2)){
output.writeUTF(dir + filenames[i]);
}
Run Code Online (Sandbox Code Playgroud)
这是代码的一小部分.我喜欢它,以便它跳过"00"并仍然将其识别为"几乎"相同的数字并仍然输出它.
我想它会看起来像什么,String em2 = "524"+ ## +"646"但这显然只是一个概念
有没有人知道是否有办法拥有这种"通配符"(我从uni SQL中选择的一个术语),或者是否有另一种方法来做这种相似类型的交易.
谢谢 :)
.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
try{
ta.append("Searching Initiated at: "+datetime()+"\n");
gui.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
task.execute();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
gui.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
});
//Enable the next stage in the YD process and disable the previously executed functions
clusAn.setEnabled(true);
open.setEnabled(false);
statCl.setEnabled(false);
}catch (Exception IOE){
}
}
});
Run Code Online (Sandbox Code Playgroud)
嗨,我设计的这个应用程序的最后阶段有点痛苦.
基本上,当用户点击按钮时,我会喜欢它,所以光标变成'等待'版本,然后一旦后台进程(task.execute)完成,光标就会恢复正常.
task.execute不在同一个类中,因此我不能直接调用"gui.setCursor",因为它不能将GUI识别为变量.
不知道该怎么做,所以任何建议都会很棒
感谢:D
这是我今天早上在这里提出的一个问题的延伸,所以如果你认为你之前看过这个代码,请不要忽视:D
for (String name : filenames) {
FileInputStream in = new FileInputStream(input.readUTF());
int byteCounter = 0;
int rowCounter = 0;
long bufferCounter = 0;
byte[] b = new byte[10];
int read;
//in.skip(10);
//while((read = in.read()) != -1){
while((read = in.read(b, 0, 10)) != -1){
byteCounter ++;
if (byteCounter != 1000){
if (rowCounter == 1){
System.out.println("\n");
rowCounter = 0;
}
System.out.print(org.apache.commons.codec.binary.Hex.encodeHexString(b));
bufferCounter ++;
rowCounter ++;
}else{
byteCounter = 0;
try{
Thread.sleep(200);
}catch(InterruptedException e) {
}
}
}
System.out.println("\n"+"================"+"\n");
}
Run Code Online (Sandbox Code Playgroud)
嗨,经过几个小时的努力才能得到这个代码,我几乎完成了我正在处理的特定组件.该程序接收一个指定的文件,并应该将该文件的前10个字节转换为Hex.一旦它获取了该文件的前10个字节,它应该停止并移动到下一个指定的文件.目前,它占用整个文件并将其分成多个10字节"块"然后打印出来.换句话说,它在我认为读取的前10个字节之后没有停止(byte [] …
java ×3
comparison ×1
cursor ×1
file ×1
file-io ×1
hex ×1
inputstream ×1
invokelater ×1
swing ×1
wildcard ×1