- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的项目在通过毕业时遇到问题..我尝试制作一个考勤指纹系统..
我的问题是当我扫描指纹并保存指纹模板时..然后我关闭我的netbeans...保存文件未保存,正在被删除...如果我想验证它们,我必须再次扫描我的指纹..
任何人都可以帮助我解决问题..
谢谢...
+++ 这里是代码+++
import java.io.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.digitalpersona.onetouch.*;
public class MainForm extends JFrame
{
public static String TEMPLATE_PROPERTY = "template";
private DPFPTemplate template;
private String file;
public class TemplateFileFilter extends javax.swing.filechooser.FileFilter {
@Override public boolean accept(File f) {
return f.getName().endsWith(".fpt");
}
@Override public String getDescription() {
return "Fingerprint Template File (*.fpt)";
}
}
MainForm() {
setState(Frame.NORMAL);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setTitle("Verifikasi dan Pendaftaran Sidik Jari");
setResizable(false);
final JButton enroll = new JButton("Pendaftaran Sidik Jari");
enroll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { onEnroll(); }});
final JButton verify = new JButton("Verifikasi Sidik Jari");
verify.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { onVerify(); }});
final JButton save = new JButton("Simpan");
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { onSave(); }});
final JButton load = new JButton("Baca Template");
load.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { onLoad(); }});
final JButton quit = new JButton("Tutup");
quit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { System.exit(0); }});
this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
verify.setEnabled(template != null);
save.setEnabled(template != null);
if (evt.getNewValue() == evt.getOldValue()) return;
if (template != null)
JOptionPane.showMessageDialog(MainForm.this, "Template sidik jari siap untuk verifikasi sidik jari.", "Pendaftaran Sidik Jari", JOptionPane.INFORMATION_MESSAGE);
onSave();
}
});
JPanel center = new JPanel();
center.setLayout(new GridLayout(4, 1, 0, 5));
center.setBorder(BorderFactory.createEmptyBorder(20, 20, 5, 20));
center.add(enroll);
center.add(verify);
center.add(save);
center.add(load);
JPanel bottom = new JPanel(new FlowLayout(FlowLayout.TRAILING));
bottom.setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 20));
bottom.add(quit);
setLayout(new BorderLayout());
add(center, BorderLayout.CENTER);
add(bottom, BorderLayout.PAGE_END);
pack();
setSize((int)(getSize().width*1.6), getSize().height);
setLocationRelativeTo(null);
setTemplate(null);
setVisible(true);
}
private void onEnroll() {
EnrollmentForm form = new EnrollmentForm(this);
form.setVisible(true);
}
private void onVerify() {
VerificationForm form = new VerificationForm(this);
form.setVisible(true);
}
private void onSave() {
JFileChooser chooser = new JFileChooser();
chooser.addChoosableFileFilter(new TemplateFileFilter());
while (true) {
if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
try {
File file = chooser.getSelectedFile();
//file="xxx";
if (!file.toString().toLowerCase().endsWith(".fpt"))
file = new File(file.toString() + ".fpt");
// file=file.toString()+".fpt";
if (file.exists()) {
int choice = JOptionPane.showConfirmDialog(this,
String.format("File \"%1$s\" sudah ada.\nApakah mau mengganti?", file.toString()),
"Penyimpanan Sidik Jari",
JOptionPane.YES_NO_CANCEL_OPTION);
if (choice == JOptionPane.NO_OPTION)
continue;
else if (choice == JOptionPane.CANCEL_OPTION)
break;
}
FileOutputStream stream = new FileOutputStream(file);
stream.write(getTemplate().serialize());
stream.close();
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, ex.getLocalizedMessage(), "Penyimpanan Sidik Jari", JOptionPane.ERROR_MESSAGE);
}
}
break;
}
}
private void onLoad() {
JFileChooser chooser = new JFileChooser();
chooser.addChoosableFileFilter(new TemplateFileFilter());
if(chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
try {
FileInputStream stream = new FileInputStream(chooser.getSelectedFile());
byte[] data = new byte[stream.available()];
stream.read(data);
stream.close();
DPFPTemplate t = DPFPGlobal.getTemplateFactory().createTemplate();
t.deserialize(data);
setTemplate(t);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, ex.getLocalizedMessage(), "Loading Proses ", JOptionPane.ERROR_MESSAGE);
}
}
}
public DPFPTemplate getTemplate() {
return template;
}
public void setTemplate(DPFPTemplate template) {
DPFPTemplate old = this.template;
this.template = template;
firePropertyChange(TEMPLATE_PROPERTY, old, template);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MainForm();
}
});
}
}
最佳答案
在 onSave 方法中,您尝试使用以下方式获取文件名:
file.toString()
你应该这样做:
file.getName()
toString()
以字符串形式返回对象。
*已编辑*对于File,toString返回文件的路径,原始代码在这里是正确的。
要确保字节写入文件,您应该使用:
file.flush()
或者使用 ObjectOutputStream。它的 write(byte[]) 会阻塞,直到字节实际写入
FileOutputStream stream = new FileOutputStream(file);
ObjectOutputStream out = new ObjectOutputStream(stream);
out.writeObject(getTemplate().serialize());
out.flush();
out.close();
stream.close();
关于java - (ASK) 临时指纹扫描仪保存文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15923684/
BizTalk 将内部 SFTP 测试的指纹视为ssh-rsa 2048 33:88:f0:ff:63:78:a9:2b:3f:09:cb:05:81:db:59:86 WinSCP 显示:ssh-e
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我正在尝试实现 Android-6.0-marshmallow 中引入的指纹,但遇到了一个问题。 问题是当我尝试运行此处提供的示例代码时 android-FingerprintDialog 它不止一次
我正在寻找一种算法来匹配两个整数数组。例如: 引用: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 候选人: FF FF FF 01 02 03 FF
在 musicg 中,我可以通过以下代码比较 Wave 文件的指纹: double score = new FingerprintsSimilarity( new Wave("voice1.w
我的目标是实现第三方网站证书的 SHA1 指纹。我可以使用 openssl 成功获取它但是,当我尝试使用 python 代码实现它时,它并没有变得相同。使用 python 代码获取的 SHA1 指纹与
我正在编写一个脚本来查找大型图像库中的重复项。目前我正在做一个两遍过滤器,首先找到相同大小的文件,然后在 10240 字节的文件上执行 sha256 以获得具有相同大小的文件的指纹(代码 here )
我需要对 GitHub 进行 SSH key 审核,但我不确定如何找到我的 RSA key 指纹。我最初按照指南在 Linux 上生成 SSH key 。 我需要输入什么命令来查找我当前的 RSA k
对于历史,我有一个带有 OS debian 的本地 VM(Virtualbox),在这个 VM 中我开发了一个 Web 应用程序。我使用 ssh 协议(protocol)登录。 今天,我面临一个奇怪的
我正在使用带 sprockets 的中间人将我的 js 和 css 文件打包到一个文件中。这很好用。但是我想知道是否可以在中间人中启用 sprockets 的指纹功能。 例如我的文件 all.js,其
在 MVC 应用程序中,我需要验证客户端证书是否由特定 CA 签名/颁发。 我知道如何获取 Request.ClientCertificate和 X509Certificate2从中,但我无法弄清楚如
我正在开发一个 Android 应用程序,该应用程序将使用手机的指纹传感器作为扫描仪来验证候选人,以与数据库中已存储的指纹进行比较。我该怎么办? 最佳答案 Android 的指纹功能仅用于根据设备对用
我们正在整合 Universal App Links .该设置需要将名为 assetlinks.json 的文件上传到 Web 服务,以便验证关联。 为调试版本生成指纹时,使用默认的 debug.ke
我目前正努力为我正在开发的 Unity3d 应用程序提供一些安全性,我想添加验证 apk 文件未被某些补丁程序篡改。我知道如何从构建的应用程序(如 keytool)获取 keystore 指纹,但我很
我正在尝试将 android Fingerprint 实现到示例应用程序中。使用的密码未被识别为有效 - 但我不知道为什么,因为基于 android 文档,它应该受到支持。 密码建立在: return
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
我正在从 Google 获取 Google Play API key ,它要求输入 SHA1 指纹。我想知道什么是 SHA1 指纹?我还想知道是否可以从另一台计算机使用此 API key ? 最佳答案
我目前在非常轻量级(低处理器/低内存)的 Linux 设备上的 bash 脚本中使用 linux md5sum 命令来返回并记录单个目录中数千个名称相似的 32MB 文件的校验和。 md5sum ./
我正在尝试实现一种与我的后端服务器通信的方法,并确保我的后端仅在调用我的应用程序时才应答。 所以我的想法是,我只是将 SHA1/MD5 指纹与 HTTPS POST 请求一起发送,并在后端服务器上对其
这里有一些主题对如何查找相似图片非常有帮助。 我想做的是获取一张图片的指纹,在数码相机拍摄的不同照片上找出同一张照片。 SURF 算法似乎是独立于缩放、角度和其他失真的最佳方法。 我使用 OpenCV
我是一名优秀的程序员,十分优秀!