当前位置: 首页>>代码示例>>Java>>正文


Java Connector.READ属性代码示例

本文整理汇总了Java中javax.microedition.io.Connector.READ属性的典型用法代码示例。如果您正苦于以下问题:Java Connector.READ属性的具体用法?Java Connector.READ怎么用?Java Connector.READ使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.microedition.io.Connector的用法示例。


在下文中一共展示了Connector.READ属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: 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

示例5: 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

示例6: checkReadMode

protected void checkReadMode() throws IOException {
    if ((mode & Connector.READ) == 0) {
        throw new IOException("Invalid mode: " + mode);
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:5,代码来源:BluetoothConnection.java

示例7: openInputStream

/**
    * Returns an input stream for this socket.
    *
    * @return     an input stream for reading bytes from this socket.
    * @exception  IOException  if an I/O error occurs when creating the
    *                          input stream.
    */
   synchronized public InputStream openInputStream() throws IOException {
       if ((mode & Connector.READ) == 0)
    throw new IOException("Connection not open for reading");   
return (ssc.openInputStream());
   }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:12,代码来源:Protocol.java


注:本文中的javax.microedition.io.Connector.READ属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。