本文整理汇总了Java中javax.microedition.io.Connector.WRITE属性的典型用法代码示例。如果您正苦于以下问题:Java Connector.WRITE属性的具体用法?Java Connector.WRITE怎么用?Java Connector.WRITE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.microedition.io.Connector
的用法示例。
在下文中一共展示了Connector.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;
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
}
示例5: checkWriteMode
protected void checkWriteMode() throws IOException {
if ((mode & Connector.WRITE) == 0) {
throw new IOException("Invalid mode: " + mode);
}
}
示例6: openOutputStream
/**
* Returns an output stream for this socket.
*
* @return an output stream for writing bytes to this socket.
* @exception IOException if an I/O error occurs when creating the
* output stream.
*/
synchronized public OutputStream openOutputStream() throws IOException {
if ((mode & Connector.WRITE) == 0)
throw new IOException("Connection not open for writing");
return (ssc.openOutputStream());
}