只想要尽量简洁的代码,越简单越好,就是想把刚拍照好的图片上传到例如网站是http://www.a.com/这样
请问怎么实现?不想服务器端也有java程序
跪求代码,初学,没代码看不懂
请问怎么实现?不想服务器端也有java程序
跪求代码,初学,没代码看不懂
解决方案 »
- android系统太烂了,火不了多久
- 关于 Location Controls不能设置的问题
- 在NDK层用SKIA出现了看不懂的LOG消息----no context for glyph 0,不知道什么意思?!
- 求解一下有关验证码图片的存储和调用问题
- 关于android界面设计(求指点)
- 求助:使用NDK编程,fread读取文件,返回值总是0?
- 如何调用系统的wifi管理界面
- Android图标比别人的小是怎么回事
- AsyncTask中的onPostExecute没有执行
- Android Studio
- 如何处理多个接收包
- Activity中的onPause(),onStart(),onDestory()方法主要是做什么用的?
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;public class HttpPost { public String sendPost(String url,String content,Map<String,String> head){ try{
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(url).openConnection();
httpURLConnection.setRequestProperty("accept", "*/*");
httpURLConnection.setRequestProperty("connection", "Keep-Alive");
httpURLConnection.setRequestProperty("Content-Length", String.valueOf(content.length()));
if(head!=null){
for(String key:head.keySet()){
httpURLConnection.setRequestProperty(key,head.get(key));
}
}
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream out= httpURLConnection.getOutputStream();
out.write(content.getBytes("UTF-8"));
out.flush();
if(httpURLConnection.getResponseCode()==200){
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
StringBuilder returnStr=new StringBuilder();
String line="";
while ((line = bufferedReader.readLine()) != null) {
returnStr.append(line);
}
bufferedReader.close();
return returnStr.toString();
}else{
return null;
}
}catch(Exception e){
e.printStackTrace();
return null;
}
}
}