List of usage examples for javax.imageio.stream FileImageInputStream length
public long length()
From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java
private void startRead() { new SwingWorker<String, Void>() { @Override/* w w w.j a v a2 s .co m*/ protected String doInBackground() throws Exception { int result; IdCard idCard = new IdCard(); String photoPath = System.getProperty("user.dir") + "/temp/" + "idCard.bmp"; WString imageFile = new WString(photoPath); result = IdCardLibrary.INSTANCE.OpenCardReader(0, 4, 115200); if (result != 0) { showErrorMsg(IdCard.getErrorMsg(result)); return null; } try { result = IdCardLibrary.INSTANCE.GetPersonMsgW(idCard, imageFile); if (result == 0) { uiName.setText(idCard.getName()); uiNamePy.setText(PinyinUtil.getPinpin(idCard.getName())); uiIdCard.setText(idCard.getCardId()); uiGender.setText(idCard.getSex()); uiBirthday.setText(idCard.getBirthday()); uiAge.setText(Integer.toString(Utils.getAge(idCard.getBirthday()))); uiCensusAddress.setText(idCard.getAddress()); RenderedImage imgOri = ImageIO.read(new File(photoPath)); File imgFile = File.createTempFile("photo_", ".png", new File(System.getProperty("user.dir") + "/temp")); ImageIO.write(imgOri, "png", imgFile); uiPhoto.setImage(imgFile.getPath()); uiPhoto.putClientProperty("path", imgFile.getPath()); FileImageInputStream fiis = new FileImageInputStream(new File(imgFile.getPath())); byte[] photoByte = new byte[(int) fiis.length()]; fiis.read(photoByte); fiis.flush(); fiis.close(); uiPhoto.putClientProperty("photo", photoByte); IdCardLibrary.INSTANCE.CloseCardReader(); } Thread.sleep(1000); } catch (Exception e) { showErrorMsg(e); } return null; } }.execute(); }