Search in sources :

Example 1 with BufferedOutputStream

use of com.codename1.io.BufferedOutputStream in project CodenameOne by codenameone.

the class AndroidImplementation method openOutputStream.

/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection, int offset) throws IOException {
    String con = (String) connection;
    con = removeFilePrefix(con);
    RandomAccessFile rf = new RandomAccessFile(con, "rw");
    rf.seek(offset);
    FileOutputStream fc = new FileOutputStream(rf.getFD());
    BufferedOutputStream o = new BufferedOutputStream(fc, con);
    o.setConnection(rf);
    return o;
}
Also used : RandomAccessFile(java.io.RandomAccessFile) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream)

Example 2 with BufferedOutputStream

use of com.codename1.io.BufferedOutputStream in project CodenameOne by codenameone.

the class AndroidImplementation method openOutputStream.

/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        String con = (String) connection;
        if (con.startsWith("file://")) {
            con = con.substring(7);
        }
        OutputStream fc = createFileOuputStream((String) con);
        BufferedOutputStream o = new BufferedOutputStream(fc, (String) con);
        return o;
    }
    return new BufferedOutputStream(((URLConnection) connection).getOutputStream(), connection.toString());
}
Also used : BufferedOutputStream(com.codename1.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream)

Example 3 with BufferedOutputStream

use of com.codename1.io.BufferedOutputStream in project CodenameOne by codenameone.

the class IOSImplementation method openOutputStream.

/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        BufferedOutputStream o = new BufferedOutputStream(new NSDataOutputStream((String) connection), (String) connection);
        return o;
    }
    NetworkConnection n = (NetworkConnection) connection;
    n.body = new FileBackedOutputStream();
    return new BufferedOutputStream(n.body);
}
Also used : BufferedOutputStream(com.codename1.io.BufferedOutputStream)

Example 4 with BufferedOutputStream

use of com.codename1.io.BufferedOutputStream in project CodenameOne by codenameone.

the class GameCanvasImplementation method openOutputStream.

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

Example 5 with BufferedOutputStream

use of com.codename1.io.BufferedOutputStream in project CodenameOne by codenameone.

the class BlackBerryOS5Implementation method openOutputStream.

/**
 * (non-Javadoc)
 *
 * @see
 * com.codename1.impl.blackberry.BlackBerryImplementation#openOutputStream(java.lang.Object)
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        return super.openOutputStream(connection);
    }
    OutputStream os = ((HttpConnection) connection).openOutputStream();
    // getSoftwareVersion() not available in legacy port,introduced at API 4.3.0
    int majorVersion = DeviceInfo.getSoftwareVersion().charAt(0) - '0';
    // in version 7, BBOS started supporting HTTP 1.1, so facade not required.
    if (majorVersion < 7) {
        os = new BlackBerryOutputStream(os);
    }
    return new BufferedOutputStream(os, ((HttpConnection) connection).getURL());
}
Also used : HttpConnection(javax.microedition.io.HttpConnection) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream) OutputStream(java.io.OutputStream) BufferedOutputStream(com.codename1.io.BufferedOutputStream)

Aggregations

BufferedOutputStream (com.codename1.io.BufferedOutputStream)10 OutputStream (java.io.OutputStream)4 FileConnection (javax.microedition.io.file.FileConnection)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 CodenameOneImplementation (com.codename1.impl.CodenameOneImplementation)1 FontFormatException (java.awt.FontFormatException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataOutputStream (java.io.DataOutputStream)1 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 RandomAccessFile (java.io.RandomAccessFile)1 SQLException (java.sql.SQLException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 HttpConnection (javax.microedition.io.HttpConnection)1