當前位置: 首頁>>代碼示例>>Java>>正文


Java Connector.READ_WRITE屬性代碼示例

本文整理匯總了Java中javax.microedition.io.Connector.READ_WRITE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Connector.READ_WRITE屬性的具體用法?Java Connector.READ_WRITE怎麽用?Java Connector.READ_WRITE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.microedition.io.Connector的用法示例。


在下文中一共展示了Connector.READ_WRITE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: open

public Connection open(String protocol, String url, int mode, boolean timeouts) throws IOException {
    
    if(protocol == null || protocol.length()==0){
        throw new IllegalArgumentException("Protocol cannot be null or empty");
    }
    
    if (mode != Connector.READ && mode != Connector.WRITE && mode != Connector.READ_WRITE) {
        throw new IllegalArgumentException("illegal mode: " + mode);
    }
    
    if (opened) {
        throw new IOException("already connected");
    }
    
    this.url = url;
    this.mode = mode;
    this.timeouts = timeouts;
    parseURL();
    opened=true;
    opens++;
    return this;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:22,代碼來源:Protocol.java

示例2: openInputStream

public InputStream openInputStream() throws IOException {

        if (in != null) {
            throw new IOException("already open");
        }

        // If the connection was opened and closed before the
        // data input stream is accessed, throw an IO exception
        if (!opened) {
            throw new IOException("connection is closed");
        }

        // Check that the connection was opened for reading
        if (mode != Connector.READ && mode != Connector.READ_WRITE) {
            throw new IOException("write-only connection");
        }

        connect();
        opens++;
        in = new PrivateInputStream();
        return in;
    }
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:22,代碼來源:Protocol.java

示例3: openOutputStream

public OutputStream openOutputStream() throws IOException {

        if (mode != Connector.WRITE && mode != Connector.READ_WRITE) {
            throw new IOException("read-only connection");
        }

        // If the connection was opened and closed before the
        // data output stream is accessed, throw an IO exception
        if (!opened) {
            throw new IOException("connection is closed");
        }

        if (out != null) {
            throw new IOException("already open");
        }

        opens++;
        out = new PrivateOutputStream();
        return out;
    }
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:20,代碼來源:Protocol.java

示例4: openFile

protected File openFile( String filename, boolean readMode, boolean appendMode, boolean updateMode, boolean binaryMode ) throws IOException {
	String url = "file:///" + filename;
	int mode  = readMode? Connector.READ: Connector.READ_WRITE;
	StreamConnection conn = (StreamConnection) Connector.open( url, mode );
	File f = readMode? 
			new FileImpl(conn, conn.openInputStream(), null):
			new FileImpl(conn, conn.openInputStream(), conn.openOutputStream());
	/*
	if ( appendMode ) {
		f.seek("end",0);
	} else {
		if ( ! readMode )
			conn.truncate(0);
	}
	*/
	return f;
}
 
開發者ID:gnosygnu,項目名稱:luaj_xowa,代碼行數:17,代碼來源:JmeIoLib.java

示例5: connect

/**
 * @inheritDoc
 */
public Object connect(String url, boolean read, boolean write) throws IOException {
    int mode;
    if(read && write) {
        mode = Connector.READ_WRITE;
    } else {
        if(write) {
            mode = Connector.WRITE;
        } else {
            mode = Connector.READ;
        }
    }
    return Connector.open(url, mode);
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:16,代碼來源:GameCanvasImplementation.java

示例6: checkOpenMode

private void checkOpenMode(int mode)  throws IllegalArgumentException {
    if (mode != Connector.READ_WRITE &&
        mode != Connector.READ &&
        mode != Connector.WRITE) {
        throw new IllegalArgumentException("Unsupported mode: " + mode);
    }
}
 
開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:7,代碼來源:BluetoothProtocol.java


注:本文中的javax.microedition.io.Connector.READ_WRITE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。