Package blackberry.io.file.FileProperties

Examples of blackberry.io.file.FileProperties.FilePropertiesObject


     *
     *            IOException will be thrown if src file does not yet exist, or the src path is a directory
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        FileConnectionWrapper fConnWrap = null;
        FilePropertiesObject fileProObj = null;

        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );
            ExtendedFileConnection fConn = (ExtendedFileConnection) fConnWrap.getFileConnection();

            Boolean isReadonly = new Boolean( !fConn.canWrite() );
            Boolean isHidden = new Boolean( fConn.isHidden() );
            Double size = new Double( fConn.fileSize() );
            Date dateModified = new Date( fConn.lastModified() );

            int dotIndex = ( args[ 0 ].toString() ).lastIndexOf( (int) '.' );
            String fileExtension = "";
            if( dotIndex >= 0 ) {
                fileExtension = ( args[ 0 ].toString() ).substring( dotIndex );
            }

            String directory = "file://" + fConn.getPath();
            String mimeType = MIMETypeAssociations.getMIMEType( fConn.getName() );
            if( mimeType == null ) {
                mimeType = "";
            }

            // get the character encoding by scanning the first 2-4 bytes
            byte[] data = null;
            if( size.intValue() >= 2 ) {
                data = new byte[ 4 ];
                DataInputStream dis = fConnWrap.openDataInputStream();
                dis.read( data, 0, 4 ); // IOException may be thrown
            }
            String encoding = getEncoding( data );
            fileProObj = new FilePropertiesObject( isReadonly, isHidden, size, null, dateModified, fileExtension, directory,
                    mimeType, encoding );

        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
View Full Code Here

TOP

Related Classes of blackberry.io.file.FileProperties.FilePropertiesObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.