ã«ã¡ã©ã使ã£ã¦éæ¢ç»ãã¼ã¿ã®åå¾ï¼S!ã¢ããªï¼
CameraConnectionã§å®ç¾å¯è½ãªãã¨
- ãã¤ãã£ãã·ã¹ãã ããµãã¼ãããæ®å½±ç¨ã®ãã©ã¡ã¼ã¿ã®åå¾
- æ®å½±ç¨ãã©ã¡ã¼ã¿ã®åå¾ããã³è¨å®
- ãã¬ã¼ã ç»åã®è¨å®
- æ®å½±ãã¼ã¿ã®åå¾
MIDP | javax.microedition.io.Connector |
JSCL-1.2.X以éã¾ãã¯MEXA1.0以é | com.j_phone.io.CameraConnection com.j_phone.io.StorageConnection |
ãµã³ãã«ã½ã¼ã¹
CameraConnection cc = (CameraConnection)Connector.open("camera:"); cc.capture(); String filename = cc.getFileName(); cc.close(); StorageConnection sc = (StorageConnection)Connector.open("file://" + filename); byte[] data = new byte[(int)sc.getLength()]; InputStream is = sc.openInputStream(); is.read(data); is.close(); sc.close();
JADãã¡ã¤ã«
ã«ã¡ã©æ©è½ã¨ãã¡ã¤ã«æ©è½ã¸ã®ã¢ã¯ã»ã¹ã¯ãã»ãã¥ãªãã£ã«å¼ã£ãããã®ã§ãMIDlet-Permissionsãã®è¨è¼ãå¿ è¦
MIDlet-Version: 1.0 MicroEdition-Profile: MIDP-2.0 MicroEdition-Configuration: CLDC-1.1 MIDlet-Permissions: com.j_phone.io.Connector.CameraConnection.capture,com.j_phone.io.Connector.StorageConnection.read MIDxlet-API: JSCL-1.2.2
çµæ
byte[]ã®dataã«æ®å½±ç»åã®ãã¤ããªãæ ¼ç´ããã
å¿ è¦ãªä¾å¤å¦ç
Connector#open
IllegalArgumentException - ãã©ã¡ã¼ã¿ãç¡å¹ã¾ãã¯èª¤ãã®ããå ´åã« throw ãã¾ãã
ConnectionNotFoundException - è¦æ±ããã url ã«å¯¾å¿ããæ¥ç¶ãè¡ãç¡ãå ´åãããã¯æå®ããããããã³ã«åãããã¤ã¹ã«ãã£ã¦ãµãã¼ããããªãå ´åã« throw ãã¾ãã
IOException - ä¸è¨ä»¥å¤ã®ä½ããã®ä¾å¤ãçºçããå ´åã« throw ãã¾ãã
Connector#close
IOException
CameraConnection#caputure
IOException - ãã¤ãã£ãã·ã¹ãã ã§ãµãã¼ããã¦ããªãç»åãµã¤ãºãç»åä¿åå½¢å¼ãç»åå質ãæå®ãããå ´åãã¾ãã¯æ®å½±æã«ã¨ã©ã¼ãçºçããå ´åã«çºçããã
StorageConnection#getLength
IOException - 以ä¸ã®å ´åã«çºçãã
- ã³ãã¯ã·ã§ã³ãéãã¦ãã
- æå®ããããã¡ã¤ã«ã¾ãã¯ãã©ã«ããåå¨ããªããã¾ã㯠Java ã¢ããªã±ã¼ã·ã§ã³ããä¸å¯è¦
- ãã®ä»ã®å ¥åºåã¨ã©ã¼
StorageConnection#openInputStream
SecurityException - ã¢ã¯ã»ã¹ã®å¶éããã Java ã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºãããå ´åãã¾ãã¯èä½æ¨©ä¿è·ãã¼ã¿ãã¡ã¤ã«ã®å ´åã«çºçãã
java.io.IOException - 以ä¸ã®å ´åã«çºçãã
- Connector.open() ã®å¼æ°modeã« Connector.WRITEãæå®ããã
- ã³ãã¯ã·ã§ã³ãéãã¦ãã
- æå®ããããã¹åãã«ã¼ãã¾ãã¯ãã©ã«ãã示ãã¦ãã
- æå®ããããã¡ã¤ã«ãåå¨ããªããã¾ã㯠Java ã¢ããªã±ã¼ã·ã§ã³ããä¸å¯è¦
- æå®ããããã¡ã¤ã«ã¾ãã¯ä»ã®ãã¡ã¤ã«ã«å¯¾ãã¦ã¹ããªã¼ã ãéãã¦ãã
- ãã®ä»ã®å ¥åºåã¨ã©ã¼
InputStream#read
IOException - å ¥åºåã¨ã©ã¼ãçºçããå ´å
InputStream#close
IOException - å ¥åºåã¨ã©ã¼ãçºçããå ´å
解説
Connectorã¯ã©ã¹ã®openã¡ã½ããã«ãcamera:ãã¹ãã¼ã ãæå®ãããã¨ã§CameraConnectionã¤ã³ã¿ãã§ã¼ã¹ãå®è£ ãããªãã¸ã§ã¯ããåå¾ã§ãããããã§ä½¿ããCameraConnectionããStorageConnectionãã¯ãã¨ãã«ãjavax.microedition.io.Connectionããç¶æ¿ãã¦ããã®ã§ãConnectorã¯ã©ã¹ããçæãããã¨ã«ãªãã
ãã®å¾ãCameraConnectionã¤ã³ã¿ãã§ã¼ã¹ã®captureã¡ã½ããã§æ®å½±ãåã¤ã³ã¿ãã§ã¼ã¹ã®getFileNameã¡ã½ããã«ãããæ®å½±ãã¼ã¿ã®ãã¡ã¤ã«åãåå¾ã§ãããConnectionã¤ã³ã¿ãã§ã¼ã¹ã®closeã¡ã½ãããå¼ã³åºããã¨ã§ãã«ã¡ã©æ©è½ãçµäºããã
æå¾ã«åå¾ãããã¡ã¤ã«åãå ã«ãStorageConnectionãªãã¸ã§ã¯ããå©ç¨ãã¦ãã¡ã¤ã«ã«ã¢ã¯ã»ã¹ããInputStreamãªãã¸ã§ã¯ããéãã¦ãã¼ã¿ãåå¾ããã
ãªããCameraConnectionãªãã¸ã§ã¯ããåå¾ããå¾ã«æ®å½±ç»åã®ãµã¤ãºãä¿åå½¢å¼ãç»åå質ããã¬ã¼ã ç»åãæå®ãã¦ããæ®å½±ãããã¨ãå¯è½ã§ãã«ã¡ã©åä½æã¯ã¢ããªã®ã¹ã¬ããã¯åæ¢ããç¶æ ã¨ãªãã
ãªããã¨ãã¥ã¬ã¼ã¿ã§ã¯ãStorageConnection sc = (StorageConnection)Connector.open("file://" + filename);ãã®é¨åã§ãjava.io.IOExceptionï¼invalid rootï¼ããçºçããããããããfilenameãã«ãc:\â¦ããå ¥ã£ã¦ãããã¨ãåå ã¨æããããï¼ç«¯æ«ä¸ã®ãã¹ã¯æ©å¨å é¨ã®ãã¼ã¿ãã©ã«ãã§ããã°ã/ms/â¦ãã¨ãªãã¯ããªã®ã§ï¼
ä¸è¨ã½ã¼ã¹ã¯å®æ©ï¼911Tï¼ã§åä½ç¢ºèªæ¸ã¿ã
â»ã¹ãã¼ã ・・・URLã®ãhttp:ãããresource:ãããfile:ããªã©ã®é¨å
åèURL
MIDP 2.0対応端末編 1.0.2 2007-07-20
MEXA/JSCL利用編 Appendix A 1.0.1 2007-07-20
é¢é£ãã¼ã¯ã¼ã
OpticalDeviceConnection
VideoConnection