Package blackberry.io

Examples of blackberry.io.FileConnectionWrapper


     *
     * @param args
     *            args[0] a complete URL path to a directory that is to be renamed args[1] the URL used for renaming
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );

            if( !fConnWrap.exists() ) {
                throw new FileIOException( FileIOException.DIRECTORY_NOT_FOUND );
            }

            if( !fConnWrap.isDirectory() ) {
                throw new FileIOException( FileIOException.NOT_A_DIRECTORY );
            }

            if( args[ 1 ].toString().length() == 0 ) {
                throw new FileIOException( FileIOException.NOT_A_DIRECTORY );
            }

            fConnWrap.getFileConnection().rename( args[ 1 ].toString() );
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return UNDEFINED;
    }
View Full Code Here


     */

    public Object execute( Object thiz, Object[] args ) throws Exception {

        String parentDir = null;
        FileConnectionWrapper fConnWrap = null;

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

            if( !fConnWrap.exists() ) {
                throw new FileIOException( FileIOException.FILENAME_NOT_FOUND );
            }

            parentDir = "file://" + fConnWrap.getFileConnection().getPath();
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }

        return parentDir;
    }
View Full Code Here

     * @return Amount of free space in bytes
     */

    public Object execute( Object thiz, Object[] args ) throws Exception {
        Double freeSpace = null;
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );
            freeSpace = new Double( fConnWrap.getFileConnection().availableSize() );
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return freeSpace;
    }
View Full Code Here

     *
     *            IOException will be thrown if src file does not yet exist, or the src path is to an directory
     */

    public Object execute( Object thiz, Object[] args ) throws Exception {
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );

            if( !fConnWrap.exists() ) {
                throw new FileIOException( FileIOException.FILENAME_NOT_FOUND );
            }

            if( fConnWrap.isDirectory() ) {
                throw new FileIOException( FileIOException.NOT_A_FILE );
            }

            fConnWrap.getFileConnection().rename( args[ 1 ].toString() );
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return UNDEFINED;
    }
View Full Code Here

     *            args[0]: the complete URL path to the directory
     *
     * @return Returns undefined; throws FileIOException if directory not found or if specified path is not a directory
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );

            if( !fConnWrap.exists() ) {
                throw new FileIOException( FileIOException.DIRECTORY_NOT_FOUND );
            }
            if( !fConnWrap.isDirectory() ) {
                throw new FileIOException( FileIOException.NOT_A_DIRECTORY );
            }

            // Delete all the contents of the directory if the flag is set
            if( args.length > 1 && args[ 1 ] instanceof Boolean && args[ 1 ].toString().equals( "true" ) ) {
                deleteEntireDirectory( fConnWrap );
            } else {
                fConnWrap.getFileConnection().delete();
            }
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return UNDEFINED;
    }
View Full Code Here

    public Object execute( Object thiz, Object[] args ) throws Exception {
        // whether the full path file exists and not a directory
        boolean exist = false;
        String fullPathUrl = args[ 0 ].toString();
        FileConnectionWrapper fConnWrap = null;

        try {
            fConnWrap = new FileConnectionWrapper( fullPathUrl );
            if( fConnWrap.exists() && !fConnWrap.isDirectory() ) {
                exist = true;
            }
        } catch( Exception e ) {
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }

        if( exist ) {
            if( invokeContentHandler( fullPathUrl ) ) {
View Full Code Here

        // still references to the recently deleted file that will
        // throw an IOException
        fConn.close();

        // Set the connector to the parent
        final FileConnectionWrapper newFConn = new FileConnectionWrapper( parentPath );

        return newFConn;
    }
View Full Code Here

     * @return Return true if the directory exists, false otherwise (note: if the path is to a existing file (not a directory),
     *         the method will still return false)
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        Boolean exists = null;
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );
            exists = new Boolean( fConnWrap.exists() && fConnWrap.isDirectory() );
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return exists;
    }
View Full Code Here

     *
     *            IOException will be thrown if 1. src file does not yet exist, or the src path is to an directory
     */

    public Object execute( Object thiz, Object[] args ) throws Exception {
        FileConnectionWrapper fConnWrap = null;
        DataOutputStream dos = null;

        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );
            fConnWrap.create();
            dos = fConnWrap.openDataOutputStream();
            byte[] data = ( (Blob) ( args[ 1 ] ) ).getBytes();
            dos.write( data, 0, data.length );
            dos.flush();
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return UNDEFINED;
    }
View Full Code Here

     */

    public Object execute( Object thiz, Object[] args ) throws Exception {

        Boolean exists = null;
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );

            exists = new Boolean( fConnWrap.exists() && !fConnWrap.isDirectory() );
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return exists;
    }
View Full Code Here

TOP

Related Classes of blackberry.io.FileConnectionWrapper

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.