/[projects]/dao/DaoAdresseService/src/dk/daoas/daoadresseservice/util/HttpUtil.java
ViewVC logotype

Diff of /dao/DaoAdresseService/src/dk/daoas/daoadresseservice/util/HttpUtil.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2321 by torben, Tue Feb 17 09:06:42 2015 UTC revision 2366 by torben, Tue Feb 24 12:22:26 2015 UTC
# Line 114  public class HttpUtil { Line 114  public class HttpUtil {
114                  URLConnection connection = url.openConnection();                  URLConnection connection = url.openConnection();
115                                    
116                  connection.setConnectTimeout(timeout);                  connection.setConnectTimeout(timeout);
117                    connection.setReadTimeout(timeout);
118                  InputStream is = connection.getInputStream();                  InputStream is = connection.getInputStream();
119                                    
120                  return readInputStream(is);                  return readInputStream(is);
# Line 137  public class HttpUtil { Line 138  public class HttpUtil {
138                    
139          static byte[] readInputStream(InputStream is) throws IOException{          static byte[] readInputStream(InputStream is) throws IOException{
140                  byte buffer[] = new byte[1024];                  byte buffer[] = new byte[1024];
141                  ByteArrayOutputStream baos = new ByteArrayOutputStream(32768); //start buffer size - instead of default 32bytes                  //try /; //start buffer size - instead of default 32bytes
142                  try {                  try (ByteArrayOutputStream baos = new ByteArrayOutputStream(32768)) {
143                          int count;                          int count;
144                            
145                          while ( (count = is.read(buffer)) != -1) {                          while ( (count = is.read(buffer)) != -1) {
146                                  baos.write(buffer, 0, count);                                  baos.write(buffer, 0, count);
147                          }                          }
148                  } finally {                          is.close();
149                          try {                          return baos.toByteArray();
150                                  is.close();                  }      
                                 baos.close();  
                         } catch (Exception e) {} //never mind if close throws an exception  
                 }  
                                   
                 return baos.toByteArray();                
151          }          }
152                    
153  }  }

Legend:
Removed from v.2321  
changed lines
  Added in v.2366

  ViewVC Help
Powered by ViewVC 1.1.20