Results 1 to 6 of 6
  1. #1
    scarletrain is offline Member
    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Question [ASK] Temporary Fingerprint Scanner Save File

    Hi all
    i have a problem with my project to pass the graduation..
    i try to make a attendance fingerprint system..

    my problem is when i scan my fingerprint and save my fingerprint template.. and then i close my netbeans...
    the save file is not save, being deleted... and i must scan my fingerprint again if i want to verification them..

    anyone can help my problem..

    thanks...

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: [ASK] Temporary Fingerprint Scanner Save File

    You should post some code so people can see what you're doing. Note the whole thing - or anything to do with the fingerprints as such - but what you do to save a simple file and which illustrates the problem.

  3. #3
    scarletrain is offline Member
    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Default Re: [ASK] Temporary Fingerprint Scanner Save File

    Ahh im sorry. i forgot to post the code

    ---Here the code---
    Java Code:
                                     
    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;
    		}
    	}
    Last edited by Tolls; 04-10-2013 at 11:15 AM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: [ASK] Temporary Fingerprint Scanner Save File

    Replaced your [quote] tags [/quote] with [code] tags [/code].

    What does the serialise() method return?
    Are you sure the output code is being run?
    I see no debug code in there to confirm any values being used.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    scarletrain is offline Member
    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Default Re: [ASK] Temporary Fingerprint Scanner Save File

    here is the full coding

    Java Code:
    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();
                }
            });
        }
    
    }
    Last edited by scarletrain; 04-10-2013 at 12:26 PM.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: [ASK] Temporary Fingerprint Scanner Save File

    So stick some debug in there to ensure it is going where you think it is.

    There's nothing in that code that will delete the file if it has been created.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. jar file in temporary folder
    By Boule in forum Java Applets
    Replies: 2
    Last Post: 10-25-2012, 09:39 AM
  2. fingerprint reader
    By Ravi Kurkute in forum Advanced Java
    Replies: 1
    Last Post: 10-03-2012, 05:47 PM
  3. fingerprint ridge count?
    By aho123 in forum Java 2D
    Replies: 1
    Last Post: 05-08-2010, 05:04 AM
  4. Replies: 0
    Last Post: 03-05-2010, 04:21 AM
  5. Fingerprint verification
    By venkateshcoolmoon in forum Advanced Java
    Replies: 4
    Last Post: 02-02-2010, 06:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •