本文整理了Java中java.net.URLConnection.getDoOutput()
方法的一些代码示例,展示了URLConnection.getDoOutput()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getDoOutput()
方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getDoOutput
[英]Returns the value of the option doOutput which specifies whether this connection allows to send data.
[中]返回选项doOutput的值,该选项指定此连接是否允许发送数据。
代码示例来源:origin: org.eclipse.jetty.osgi/jetty-osgi-boot-warurl
@Override
public boolean getDoOutput()
{
return _conn.getDoOutput();
}
代码示例来源:origin: org.jboss/jboss-common-core
public boolean getDoOutput() {
return delegateConnection.getDoOutput();
}
代码示例来源:origin: org.samba.jcifs/jcifs
public boolean getDoOutput() {
return connection.getDoOutput();
}
代码示例来源:origin: freeplane/freeplane
public boolean getDoOutput() {
return connection.getDoOutput();
}
代码示例来源:origin: igniterealtime/Spark
/**
* Tests whether the application can modify the resource at the
* specified {@link URL}.
*
* @return <CODE>true</CODE> if and only if the specified
* {@link URL} points to a file that exists <EM>and</EM> the
* application is allowed to write to the file; <CODE>false</CODE>
* otherwise.
*
* @param url URL to check if we can write to.
*/
public boolean canWrite(URL url) {
try {
final URLConnection urlConnection = url.openConnection();
return urlConnection.getDoOutput();
}
catch (Exception e) {
return false;
}
}
代码示例来源:origin: stackoverflow.com
public void makeXMLRequest() {
try {
URL url = new URL("http://api.androidhive.info/pizza/?format=xml");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.getDoOutput();
String readStream = readStream(con.getInputStream());
// Give output for the command line
System.out.println(readStream);
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
public void PutImageToS3(String signedUrl, Bitmap image) throws WampNetworkException, IOException {
try{
URL url = new URL(signedUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.getDoOutput();
conn.setUseCaches(false);
conn.setRequestMethod("PUT");
conn.addRequestProperty("Content-Type", "image/jpeg");
conn.addRequestProperty("Connection", "close");
OutputStream out = new BufferedOutputStream(conn.getOutputStream());
image.compress(Bitmap.CompressFormat.JPEG, 100, out);
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new IOException("Failed to upload image to S3: "
+ conn.getResponseCode() + conn.getResponseMessage() + "\r\n");
}
}
finally{
out.flush();
out.close();
conn.disconnect();
}
}
代码示例来源:origin: stackoverflow.com
private void openConnection(HttpURLConnection connection, HttpRequest request) throws IOException {
if (request.getHttpBody() != null) {
connection.setDoOutput(true);
}
connection.setRequestMethod(request.getMethod());
Map<String, String> map = request.getHeaders();
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
Logger.i("prepare headers with key = " + key + " value = " + value);
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
connection.setReadTimeout((int) mReadTimeout);
connection.setConnectTimeout((int) mConnectionTimeout);
if (connection.getDoOutput()) {
connection.connect();
}
}
代码示例来源:origin: com.senseidb/sensei-core
if (!conn.getDoOutput()) {
conn.setDoOutput(true);
os = conn.getOutputStream();
代码示例来源:origin: org.apache.cocoon.pipeline/cocoon-pipeline
if (urlConnection.getDoOutput()) {
OutputStream outputStream = null;
try {
代码示例来源:origin: org.apache.ace/org.apache.ace.gateway.log
/**
* Should be called when a <code>Connection</code> is used to do a POST (write to it's outputstream)
* without reading it's inputstream (the response). Calling this will make sure the POST request is sent.
* If no data was written to the connection nothing is done.
*/
public void close() {
if (m_connection.getDoOutput()) {
try {
m_connection.getOutputStream().close();
}
catch (IOException e) {
// not much we can do
}
try {
m_connection.getContent();
}
catch (IOException e) {
// not much we can do
}
}
if (m_connection.getDoInput()) {
try {
m_connection.getInputStream().close();
}
catch (IOException e) {
// not much we can do
}
}
}
}
代码示例来源:origin: graphstream/gs-algo
if (conn.getDoOutput())
conn.getOutputStream().close();
reader.close();
代码示例来源:origin: org.graphstream/gs-algo
if (conn.getDoOutput())
conn.getOutputStream().close();
reader.close();
代码示例来源:origin: Countly/countly-sdk-android
public void testUrlConnectionForEventData() throws IOException {
final String eventData = "blahblahblah";
final URLConnection urlConnection = connectionProcessor.urlConnectionForEventData(eventData);
assertEquals(30000, urlConnection.getConnectTimeout());
assertEquals(30000, urlConnection.getReadTimeout());
assertFalse(urlConnection.getUseCaches());
assertTrue(urlConnection.getDoInput());
assertFalse(urlConnection.getDoOutput());
assertEquals(new URL(connectionProcessor.getServerURL() + "/i?" + eventData + "&checksum=" + sha1Hash(eventData + null)), urlConnection.getURL());
}
内容来源于网络,如有侵权,请联系作者删除!