Search in sources :

Example 6 with FileConnection

use of javax.microedition.io.file.FileConnection in project CodenameOne by codenameone.

the class GameCanvasImplementation method rename.

/**
 * @inheritDoc
 */
public void rename(String file, String newName) {
    FileConnection fc = null;
    try {
        fc = (FileConnection) Connector.open(file, Connector.READ_WRITE);
        fc.rename(newName);
    } catch (IOException err) {
        err.printStackTrace();
    } finally {
        cleanup(fc);
    }
}
Also used : IOException(java.io.IOException) FileConnection(javax.microedition.io.file.FileConnection)

Example 7 with FileConnection

use of javax.microedition.io.file.FileConnection in project CodenameOne by codenameone.

the class GameCanvasImplementation method mkdir.

/**
 * @inheritDoc
 */
public void mkdir(String directory) {
    FileConnection fc = null;
    try {
        fc = (FileConnection) Connector.open(directory, Connector.READ_WRITE);
        fc.mkdir();
    } catch (IOException err) {
        err.printStackTrace();
    } finally {
        cleanup(fc);
    }
}
Also used : IOException(java.io.IOException) FileConnection(javax.microedition.io.file.FileConnection)

Example 8 with FileConnection

use of javax.microedition.io.file.FileConnection in project CodenameOne by codenameone.

the class GameCanvasImplementation method openInputStream.

/**
 * @inheritDoc
 */
public InputStream openInputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        FileConnection fc = (FileConnection) Connector.open((String) connection, Connector.READ);
        BufferedInputStream o = new BufferedInputStream(fc.openInputStream(), (String) connection);
        o.setConnection(fc);
        return o;
    }
    return new BufferedInputStream(((HttpConnection) connection).openInputStream(), ((HttpConnection) connection).getURL());
}
Also used : BufferedInputStream(com.codename1.io.BufferedInputStream) FileConnection(javax.microedition.io.file.FileConnection)

Example 9 with FileConnection

use of javax.microedition.io.file.FileConnection in project CodenameOne by codenameone.

the class GameCanvasImplementation method openOutputStream.

/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        FileConnection fc = (FileConnection) Connector.open((String) connection, Connector.READ_WRITE);
        if (!fc.exists()) {
            fc.create();
        }
        BufferedOutputStream o = new BufferedOutputStream(fc.openOutputStream(), (String) connection);
        o.setConnection(fc);
        return o;
    }
    return new BufferedOutputStream(((HttpConnection) connection).openOutputStream(), ((HttpConnection) connection).getURL());
}
Also used : BufferedOutputStream(com.codename1.io.BufferedOutputStream) FileConnection(javax.microedition.io.file.FileConnection)

Example 10 with FileConnection

use of javax.microedition.io.file.FileConnection in project CodenameOne by codenameone.

the class BlackBerryImplementation method openOutputStream.

/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        FileConnection fc = (FileConnection) Connector.open((String) connection, Connector.READ_WRITE);
        if (!fc.exists()) {
            fc.create();
        }
        BufferedOutputStream o = new BufferedOutputStream(fc.openOutputStream(), (String) connection);
        o.setConnection(fc);
        return o;
    }
    OutputStream os = new BlackBerryOutputStream(((HttpConnection) connection).openOutputStream());
    return new BufferedOutputStream(os, ((HttpConnection) connection).getURL());
}
Also used : DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream) OutputStream(java.io.OutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream) FileConnection(javax.microedition.io.file.FileConnection)

Aggregations

FileConnection (javax.microedition.io.file.FileConnection)14 IOException (java.io.IOException)8 BufferedOutputStream (com.codename1.io.BufferedOutputStream)4 BufferedInputStream (com.codename1.io.BufferedInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 OutputStream (java.io.OutputStream)1