字节流解析json

时间:2025-03-28 09:22:58
package ;

import ;
import ;
import ;
import ;



public class NetWorkUtils {

    private static ByteArrayOutputStream baos;
   static String path="/?c=index&a=index";
    public static String getjson(){

                try {
                    URL url = new URL(path);
                    HttpURLConnection connection = (HttpURLConnection) ();
                    ("GET");
                    (5000);
                    int responseCode = ();

                    baos = new ByteArrayOutputStream();

                    if(responseCode==200){
                        InputStream inputStream = ();
                        int len;
                        byte[] arr = new byte[1024];
                        while ((len=(arr))!=-1){
                            (arr,0,len);
                        }

                    }
                    return ();
                } catch (Exception e) {

                    ();
                }

        return "";
    }
}