2017-01-24 11 views
-2

연결 문자열을 버퍼 입력 스트림으로 변환하고 문자열을 json 형식으로 변경할 수 있지만 디버깅 중에 디버깅이 진행되지 않습니다. in = new BufferedInputStream(conn.getInputStream()); 및 직접 return 문으로 이동합니다. 도와주세요. 나는이 기사 다음 : = "예"
의 StringBuffer의 SBF = 새로운 StringBuffer를() https://www.tutorialspoint.com/android/android_json_parser.htm연결 문자열이 열려 있지만 진행하지 않습니다.

public String makeServiceCall(String input_url) 
{ 
    String response=null; 
    InputStream in=null; 
    StringBuffer sb = new StringBuffer(); 
    try { 

     URL url= new URL(input_url); 
     HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
     conn.setRequestMethod("GET"); 
     in = new BufferedInputStream(conn.getInputStream()); 

     BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8")); 
     String inputLine = ""; 
     while ((inputLine = br.readLine()) != null) { 
      sb.append(inputLine); 
     } 
     response = sb.toString(); 

    } 
    catch (MalformedURLException e) { 
     Log.e(TAG, "MalformedURLException: " + e.getMessage()); 
    } 
    catch (ProtocolException e) { 
     Log.e(TAG, "ProtocolException: " + e.getMessage()); 
    } 
    catch (IOException e) { 
     Log.e(TAG, "IOException: " + e.getMessage()); 
    } 
    catch (Exception e) { 
     Log.e(TAG, "Exception: " + e.getMessage()); 
    } 
    return response; 
} 
+0

나는 당신이 예외를 얻고 있다고 내기 ... 나는 NOMTException에 내기를 걸었습니다 ... – Selvin

+0

어떻게 해결할 수 있습니까? –

+0

디버깅 방법 학습 – Selvin

답변

0

문자열 STR을;

// 문자열 버퍼를 바이트로 변환 바이트 [] 바이트 = sbf.toString(). getBytes();

InputStream inputStream = new ByteArrayInputStream (bytes);