Advertisement
Guest User

DataHandler

a guest
Oct 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.76 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package apiclientdesktop;
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.BufferedWriter;
  10. import java.io.IOException;
  11. import java.io.InputStreamReader;
  12. import java.io.OutputStream;
  13. import java.io.OutputStreamWriter;
  14. import java.io.UnsupportedEncodingException;
  15. import java.net.HttpURLConnection;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18. import java.net.URLEncoder;
  19. import java.util.ArrayList;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import java.util.logging.Level;
  23. import java.util.logging.Logger;
  24. import org.json.simple.JSONArray;
  25. import org.json.simple.JSONObject;
  26. import org.json.simple.parser.JSONParser;
  27. import org.json.simple.parser.ParseException;
  28. import org.jsoup.Jsoup;
  29. import org.jsoup.nodes.*;
  30.  
  31. /**
  32.  *
  33.  * @author Asus
  34.  */
  35. public class DataHandler {
  36.  
  37.     //Provinsi
  38.     public ArrayList<Provinsi> getAllProvinsi() {
  39.         ArrayList<Provinsi> data = new ArrayList<>();
  40.         try {
  41.             URL url = new URL("http://utsppk.000webhostapp.com/api/provinsi");
  42.             HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  43.             conn.setRequestMethod("GET");
  44.             conn.setRequestProperty("Accept", "application/json");
  45.             conn.connect();
  46.             if (conn.getResponseCode() != 200) {
  47.                 throw new RuntimeException("Failed : HTTP Error code : "
  48.                         + conn.getResponseCode());
  49.             }
  50.             InputStreamReader in = new InputStreamReader(conn.getInputStream());
  51.             BufferedReader br = new BufferedReader(in);
  52.             String output;
  53.             StringBuilder result = new StringBuilder();
  54.             while ((output = br.readLine()) != null) {
  55.                 result.append(output);
  56.             }
  57.             org.json.simple.parser.JSONParser par = new org.json.simple.parser.JSONParser();
  58.             JSONArray obj = (JSONArray) par.parse(result.toString());
  59.             conn.disconnect();
  60.             in.close();
  61.             for (int i = 0; i < obj.size(); i++) {
  62.                 JSONObject pr = (JSONObject) obj.get(i);
  63.                 Provinsi p = new Provinsi();
  64.                 p.setId((String) pr.get("id"));
  65.                 p.setName((String) pr.get("name"));
  66.                 p.setPopulations(Integer.parseInt((String) pr.get("populations")));
  67.                 p.setId_weather((String) pr.get("id_weather"));
  68.                 data.add(p);
  69.  
  70.             }
  71.  
  72.         } catch (Exception e) {
  73.             System.out.println("Exception in NetClientGet:- " + e);
  74.         }
  75.  
  76.         return data;
  77.     }
  78.  
  79.     public Provinsi getProvinsi(String id) {
  80.         Provinsi p = new Provinsi();
  81.         try {
  82.             URL u = new URL("http://utsppk.000webhostapp.com/api/provinsi?idprov=" + id);
  83.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  84.             JSONParser par = new JSONParser();
  85.             conn.setRequestMethod("GET");
  86.             conn.setRequestProperty("Accept", "application/json");
  87.             conn.connect();
  88.             if (conn.getResponseCode() != 200) {
  89.                 BufferedReader er = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  90.                 String line, pesan = null;
  91.                 while ((line = er.readLine()) != null) {
  92.                     pesan += line;
  93.                 }
  94.                 pesan = pesan.substring(4);
  95.                 JSONObject gagal = (JSONObject) par.parse(pesan);
  96.                 System.out.println(gagal.get("message"));
  97.  
  98.             }
  99.             InputStreamReader in = new InputStreamReader(conn.getInputStream());
  100.             BufferedReader br = new BufferedReader(in);
  101.             String output;
  102.             StringBuilder result = new StringBuilder();
  103.             while ((output = br.readLine()) != null) {
  104.                 result.append(output);
  105.             }
  106.             JSONArray obj = (JSONArray) par.parse(result.toString());
  107.             conn.disconnect();
  108.             in.close();
  109.             JSONObject kb = (JSONObject) obj.get(0);
  110.             p.setId(kb.get("id").toString());
  111.             p.setName(kb.get("name").toString());
  112.             p.setPopulations(Integer.parseInt(kb.get("populations").toString()));
  113.             p.setId_weather(kb.get("id_weather").toString());
  114.         } catch (Exception e) {
  115. //            
  116.         }
  117.         return p;
  118.     }
  119.  
  120.     public String addProvinsi(String id, String name, int populations, String id_weather) {
  121.         HashMap<String, String> postDataParams = new HashMap<>();
  122.         postDataParams.put("id", id);
  123.         postDataParams.put("name", name);
  124.         postDataParams.put("populations", String.valueOf(populations));
  125.         postDataParams.put("id_weather", id_weather);
  126.         JSONParser par = new JSONParser();
  127.         String mesg = null;
  128.         try {
  129.             URL u = new URL("http://utsppk.000webhostapp.com/api/provinsi");
  130.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  131.             conn.setRequestMethod("POST");
  132.             conn.setDoInput(true);
  133.             conn.setDoOutput(true);
  134.  
  135.             OutputStream os = conn.getOutputStream();
  136.             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  137.             writer.write(getPostDataString(postDataParams));
  138.             writer.flush();
  139.             writer.close();
  140.             os.close();
  141.             int responseCode = conn.getResponseCode();
  142.             if (responseCode == HttpURLConnection.HTTP_CREATED) {
  143.                 String line, response = null;
  144.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  145.                 while ((line = br.readLine()) != null) {
  146.                     response += line;
  147.                 }
  148.                 response = response.substring(4);
  149.                 Document document = Jsoup.parse(response);
  150.                 Element table = document.select("table").first();
  151.                 String td = table.select("td").text();
  152.                 mesg = td;
  153.             }
  154.             if (responseCode == 400) {
  155.                 String line, response = null;
  156.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  157.                 while ((line = br.readLine()) != null) {
  158.                     response += line;
  159.                 }
  160.                 response = response.substring(4);
  161.                 Document document = Jsoup.parse(response);
  162.                 Element table = document.select("table").first();
  163.                 String td = table.select("td").text();
  164.                 mesg = td;
  165.             }
  166.         } catch (MalformedURLException ex) {
  167.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  168.         } catch (IOException ex) {
  169.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  170.         }
  171.         return mesg;
  172.     }
  173.  
  174.     public String updateProvinsi(String id, String name, int populations, String id_wether) {
  175.         String mesg = null;
  176.         HashMap<String, String> postDataParams = new HashMap<>();
  177.         postDataParams.put("id", id);
  178.         postDataParams.put("name", name);
  179.         postDataParams.put("populations", String.valueOf(populations));
  180.         postDataParams.put("id_weather", id_wether);
  181.         try {
  182.             URL u = new URL("http://utsppk.000webhostapp.com/api/provinsi/put");
  183.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  184.             conn.setRequestMethod("POST");
  185.             conn.setDoInput(true);
  186.             conn.setDoOutput(true);
  187.  
  188.             OutputStream os = conn.getOutputStream();
  189.             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  190.             writer.write(getPostDataString(postDataParams));
  191.             writer.flush();
  192.             writer.close();
  193.             os.close();
  194.             int responseCode = conn.getResponseCode();
  195.             if (responseCode == 200) {
  196.                 String line, response = null;
  197.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  198.                 while ((line = br.readLine()) != null) {
  199.                     response += line;
  200.                 }
  201.                 response = response.substring(4);
  202.                 Document document = Jsoup.parse(response);
  203.                 Element table = document.select("table").first();
  204.                 String td = table.select("td").text();
  205.                 mesg = td;
  206.             }
  207.             if (responseCode == 400) {
  208.                 String line, response = null;
  209.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  210.                 while ((line = br.readLine()) != null) {
  211.                     response += line;
  212.                 }
  213.                 response = response.substring(4);
  214.                 Document document = Jsoup.parse(response);
  215.                 Element table = document.select("table").first();
  216.                 String td = table.select("td").text();
  217.                 mesg = td;
  218.             }
  219.         } catch (MalformedURLException ex) {
  220.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  221.         } catch (IOException ex) {
  222.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  223.         }
  224.         return mesg;
  225.     }
  226.  
  227.     public String deleteProvinsi(String id) {
  228.         HashMap<String, String> postDataParams = new HashMap<>();
  229.         postDataParams.put("id", id);
  230.         String mesg = null;
  231.         try {
  232.             URL u = new URL("http://utsppk.000webhostapp.com/api/provinsi/delete");
  233.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  234.             conn.setRequestMethod("POST");
  235.             conn.setDoInput(true);
  236.             conn.setDoOutput(true);
  237.  
  238.             OutputStream os = conn.getOutputStream();
  239.             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  240.             writer.write(getPostDataString(postDataParams));
  241.             writer.flush();
  242.             writer.close();
  243.             os.close();
  244.             int responseCode = conn.getResponseCode();
  245.             if (responseCode == 200) {
  246.                 String line, response = null;
  247.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  248.                 while ((line = br.readLine()) != null) {
  249.                     response += line;
  250.                 }
  251.                 response = response.substring(4);
  252.                 Document document = Jsoup.parse(response);
  253.                 Element table = document.select("table").first();
  254.                 String td = table.select("td").text();
  255.                 mesg = td;
  256.             }
  257.             if (responseCode == 404) {
  258.                 String line, response = null;
  259.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  260.                 while ((line = br.readLine()) != null) {
  261.                     response += line;
  262.                 }
  263.                 response = response.substring(4);
  264.                 Document document = Jsoup.parse(response);
  265.                 Element table = document.select("table").first();
  266.                 String td = table.select("td").text();
  267.                 mesg = td;
  268.             }
  269.         } catch (MalformedURLException ex) {
  270.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  271.         } catch (IOException ex) {
  272.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  273.         }
  274.         return mesg;
  275.     }
  276.  
  277.     //Kabupaten
  278.     public ArrayList<Kabupaten> getAllKabupaten(String id) {
  279.         ArrayList<Kabupaten> data = new ArrayList<>();
  280.         try {
  281.             URL u = new URL("http://localhost/api-server/api/kabupaten?idprov=" + id);
  282.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  283.             JSONParser par = new JSONParser();
  284.             conn.setRequestMethod("GET");
  285.             conn.setRequestProperty("Accept", "application/json");
  286.             conn.connect();
  287.             if (conn.getResponseCode() != 200) {
  288.                 BufferedReader er = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  289.                 String line, pesan = null;
  290.                 while ((line = er.readLine()) != null) {
  291.                     pesan += line;
  292.                 }
  293.                 pesan = pesan.substring(4);
  294.                 JSONObject gagal = (JSONObject) par.parse(pesan);
  295.                 Kabupaten kab = new Kabupaten();
  296.                 kab.setId("00");
  297.                 kab.setName(gagal.get("message").toString());
  298.                 kab.setPopulations(0);
  299.                 kab.setId_weather("");
  300.                 kab.setProvince_id(id);
  301.                 data.add(kab);
  302.             } else {
  303.                 InputStreamReader in = new InputStreamReader(conn.getInputStream());
  304.                 BufferedReader br = new BufferedReader(in);
  305.                 String output;
  306.                 StringBuilder result = new StringBuilder();
  307.                 while ((output = br.readLine()) != null) {
  308.                     result.append(output);
  309.                 }
  310.                 JSONArray obj = (JSONArray) par.parse(result.toString());
  311.                 conn.disconnect();
  312.                 in.close();
  313.                 for (int i = 0; i < obj.size(); i++) {
  314.                     JSONObject kb = (JSONObject) obj.get(i);
  315.                     Kabupaten kab = new Kabupaten();
  316.                     kab.setId(kb.get("id").toString());
  317.                     kab.setName(kb.get("name").toString());
  318.                     kab.setPopulations(Integer.parseInt(kb.get("populations").toString()));
  319.                     kab.setProvince_id(kb.get("province_id").toString());
  320.                     kab.setId_weather(kb.get("id_weather").toString());
  321.                     data.add(kab);
  322.                 }
  323.             }
  324.         } catch (MalformedURLException ex) {
  325.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  326.         } catch (IOException ex) {
  327.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  328.         } catch (ParseException ex) {
  329.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  330.         }
  331.         return data;
  332.     }
  333.  
  334.     public Kabupaten getKabupaten(String id) {
  335.         Kabupaten kab = new Kabupaten();
  336.         try {
  337.             URL u = new URL("http://localhost/api-server/api/kabupaten?id=" + id);
  338.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  339.             JSONParser par = new JSONParser();
  340.             conn.setRequestMethod("GET");
  341.             conn.setRequestProperty("Accept", "application/json");
  342.             conn.connect();
  343.             if (conn.getResponseCode() != 200) {
  344.                 BufferedReader er = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  345.                 String line, pesan = null;
  346.                 while ((line = er.readLine()) != null) {
  347.                     pesan += line;
  348.                 }
  349.                 pesan = pesan.substring(4);
  350.                 JSONObject gagal = (JSONObject) par.parse(pesan);
  351.                 System.out.println(gagal.get("message"));
  352.  
  353.             }
  354.             InputStreamReader in = new InputStreamReader(conn.getInputStream());
  355.             BufferedReader br = new BufferedReader(in);
  356.             String output;
  357.             StringBuilder result = new StringBuilder();
  358.             while ((output = br.readLine()) != null) {
  359.                 result.append(output);
  360.             }
  361.             JSONArray obj = (JSONArray) par.parse(result.toString());
  362.             conn.disconnect();
  363.             in.close();
  364.             JSONObject kb = (JSONObject) obj.get(0);
  365.             kab.setId(kb.get("id").toString());
  366.             kab.setName(kb.get("name").toString());
  367.             kab.setPopulations(Integer.parseInt(kb.get("populations").toString()));
  368.             kab.setId_weather(kb.get("id_weather").toString());
  369.             kab.setProvince_id(kb.get("province_id").toString());
  370.         } catch (Exception e) {
  371. //            
  372.         }
  373.         return kab;
  374.     }
  375.  
  376.     public String addKabupaten(String idprov, String id, String name, int populations, String id_weather) {
  377.         //Insisiasi variabel yang akan di return
  378.         String mesg = null;
  379.         //Menyimpan data-data parameter yang akan dikirim
  380.         HashMap<String, String> postDataParams = new HashMap<>();
  381.         postDataParams.put("id", id);
  382.         postDataParams.put("province_id", idprov);
  383.         postDataParams.put("name", name);
  384.         postDataParams.put("populations", String.valueOf(populations));
  385.         postDataParams.put("id_weather", id_weather);
  386.         //Insisiasi parser JSON
  387.         JSONParser par = new JSONParser();
  388.         //Melakukan koneksi ke Web Service
  389.         try {
  390.             //Inisiasi Url
  391.             URL u = new URL("http://localhost/api-server/api/kabupaten");
  392.             //Mencoba open koneksi ke URL
  393.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  394.             //Mengatur parameter koneksi
  395.             conn.setRequestMethod("POST");
  396.             conn.setDoInput(true);
  397.             conn.setDoOutput(true);
  398.             //Menginisiasi Output Stream untuk mengirim param
  399.             OutputStream os = conn.getOutputStream();
  400.             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  401.             writer.write(getPostDataString(postDataParams));
  402.             writer.flush();
  403.             writer.close();
  404.             os.close();
  405.             int responseCode = conn.getResponseCode();
  406.             if (responseCode == HttpURLConnection.HTTP_CREATED) {
  407.                 String line, response = null;
  408.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  409.                 while ((line = br.readLine()) != null) {
  410.                     response += line;
  411.                 }
  412.                 response = response.substring(4);
  413.                 Document document = Jsoup.parse(response);
  414.                 Element table = document.select("table").first();
  415.                 String td = table.select("td").text();
  416.                 mesg = td;
  417.             }
  418.             if (responseCode == 400) {
  419.                 String line, response = null;
  420.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  421.                 while ((line = br.readLine()) != null) {
  422.                     response += line;
  423.                 }
  424.                 response = response.substring(4);
  425.                 Document document = Jsoup.parse(response);
  426.                 Element table = document.select("table").first();
  427.                 String td = table.select("td").text();
  428.                 mesg = td;
  429.             }
  430.  
  431.         } catch (MalformedURLException ex) {
  432.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  433.         } catch (IOException ex) {
  434.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  435.         }
  436.  
  437.         return mesg;
  438.     }
  439.    
  440.     public String updateKabupaten(String idprov, String id, String name, int populations, String id_weather, String oldid) {
  441.         String mesg = null;
  442.         HashMap<String, String> postDataParams = new HashMap<>();
  443.         postDataParams.put("id", id);
  444.         postDataParams.put("province_id", idprov);
  445.         postDataParams.put("old_id", oldid);
  446.         postDataParams.put("name", name);
  447.         postDataParams.put("populations", String.valueOf(populations));
  448.         postDataParams.put("id_weather", id_weather);
  449.         try {
  450.             URL u = new URL("http://localhost/api-server/api/kabupaten");
  451.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  452.             conn.setRequestMethod("PUT");
  453.             conn.setDoInput(true);
  454.             conn.setDoOutput(true);
  455.  
  456.             OutputStream os = conn.getOutputStream();
  457.             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  458.             writer.write(getPostDataString(postDataParams));
  459.             writer.flush();
  460.             writer.close();
  461.             os.close();
  462.             int responseCode = conn.getResponseCode();
  463.             if (responseCode == 200) {
  464.                 String line, response = null;
  465.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  466.                 while ((line = br.readLine()) != null) {
  467.                     response += line;
  468.                 }
  469.                 response = response.substring(4);
  470.                 Document document = Jsoup.parse(response);
  471.                 Element table = document.select("table").first();
  472.                 String td = table.select("td").text();
  473.                 mesg = td;
  474.             }
  475.             if (responseCode == 400) {
  476.                 String line, response = null;
  477.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  478.                 while ((line = br.readLine()) != null) {
  479.                     response += line;
  480.                 }
  481.                 response = response.substring(4);
  482.                 Document document = Jsoup.parse(response);
  483.                 Element table = document.select("table").first();
  484.                 String td = table.select("td").text();
  485.                 mesg = td;
  486.             }
  487.         } catch (MalformedURLException ex) {
  488.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  489.         } catch (IOException ex) {
  490.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  491.         }
  492.         return mesg;
  493.     }
  494.    
  495.     public String deleteKabupaten(String id) {
  496.         String mesg = null;
  497.          HashMap<String, String> postDataParams = new HashMap<>();
  498.         postDataParams.put("id", id);
  499.         try {
  500.             URL u = new URL("http://localhost/api-server/api/kabupaten");
  501.             HttpURLConnection conn = (HttpURLConnection) u.openConnection();
  502.             conn.setRequestMethod("DELETE");
  503.             conn.setDoInput(true);
  504.             conn.setDoOutput(true);
  505.  
  506.             OutputStream os = conn.getOutputStream();
  507.             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  508.             writer.write(getPostDataString(postDataParams));
  509.             writer.flush();
  510.             writer.close();
  511.             os.close();
  512.             int responseCode = conn.getResponseCode();
  513.             if (responseCode == 200) {
  514.                 String line, response = null;
  515.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  516.                 while ((line = br.readLine()) != null) {
  517.                     response += line;
  518.                 }
  519.                 response = response.substring(4);
  520.                 Document document = Jsoup.parse(response);
  521.                 Element table = document.select("table").first();
  522.                 String td = table.select("td").text();
  523.                 mesg = td;
  524.             }
  525.             if (responseCode == 400) {
  526.                 String line, response = null;
  527.                 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  528.                 while ((line = br.readLine()) != null) {
  529.                     response += line;
  530.                 }
  531.                 response = response.substring(4);
  532.                 Document document = Jsoup.parse(response);
  533.                 Element table = document.select("table").first();
  534.                 String td = table.select("td").text();
  535.                 mesg = td;
  536.             }
  537.         } catch (MalformedURLException ex) {
  538.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  539.         } catch (IOException ex) {
  540.             Logger.getLogger(DataHandler.class.getName()).log(Level.SEVERE, null, ex);
  541.         }
  542.         return mesg;
  543.     }
  544.  
  545.     //Mengatur format data yang dikirim agar sesuai standar
  546.     //misal : "name" => nama, "id"=id pada hashmap akan diubah menjadi ?name=nama&id=id
  547.     private String getPostDataString(HashMap<String, String> params) throws UnsupportedEncodingException {
  548.         StringBuilder result = new StringBuilder();
  549.         boolean first = true;
  550.         for (Map.Entry<String, String> entry : params.entrySet()) {
  551.             if (first) {
  552.                 first = false;
  553.             } else {
  554.                 result.append("&");
  555.             }
  556.  
  557.             result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
  558.             result.append("=");
  559.             result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
  560.         }
  561.  
  562.         return result.toString();
  563.     }
  564. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement