之前:

DataInputStream in = new DataInputStream(connection.getInputStream());
   byte[] b = new byte[in.available()];
in.read(b);

之后:

private String getHttpURLConnection(String url1,String paream) throws IOException, JSONException
{
Long deviceId=1l;
URL url = new URL(url1);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type","application/json;charset=utf-8");
connection.setConnectTimeout(80*1000);
connection.setReadTimeout(80*1000);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeLong(deviceId);
//最短
JSONArray array = new JSONArray(paream);
out.writeShort(array.length());
for(int i=0;i<array.length();i++){
JSONObject obj = array.getJSONObject(i);
out.write(obj.getString("time").getBytes("UTF8"));
double d = obj.getDouble("lon");
int lon = (int)(d * 1000000);
out.writeInt(lon);
d = obj.getDouble("lat") ;
int lat = (int)(d * 1000000);
out.writeInt(lat);
out.writeFloat((float)obj.getDouble("speed"));
out.writeFloat((float)obj.getDouble("direc"));
}
out.flush();
out.close();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8"));
StringBuilder sb=new StringBuilder();
String str;
while((str=br.readLine())!=null){
sb.append(str);
}
return sb.toString();
}

最新文章

  1. python已字典为元素的数组排序
  2. git免密码pull,push
  3. 。。。mkdir与mkdirs的区别。。。
  4. windows 下使用 MinGW + msys 编译 ffmpeg
  5. 让你的.NET程序支持多语言
  6. HowTo: SVN undo add without reverting local changes
  7. DataGrid( 数据表格) 组件[8]
  8. [免费活动通知]RAD Studio XE8 技术研讨会(上海、成都)
  9. IOS程序启动的过程
  10. Python编程工具IDLE快捷键
  11. 十二月总结-and-2016年终总结
  12. CLR 无法从 COM 上下文 0x208f68 转换为 COM 上下文 0x2090d8,这种状态已持续 60 秒
  13. C# Global定时执行Global文件aTimer处理
  14. python全栈开发day33-进程间的通信、进程间的数据共享,进程池
  15. Android真机测试、乐视手机启用开发者模式
  16. git命令小记
  17. SpringCloud高可用和高并发
  18. ORA-00906 missing left parenthesis括号
  19. java-&gt;php之在线子域名查询-接口光速版
  20. 常见dotNet加密保护工具分析介绍(转)

热门文章

  1. x86和i386
  2. SQLite_Home
  3. mybatis中app的查询语句
  4. (一) Docker in Docker
  5. win10下安装使用mysql-5.7.23-winx64
  6. 深入了解JVM(Java虚拟机)
  7. Vsphere中ESXi主机ssh开启的三种方法
  8. Xgboost集成算法
  9. python:第一章
  10. django insert data into mysql