feat: add WebUtils Class
This commit is contained in:
		
							parent
							
								
									46c34f137f
								
							
						
					
					
						commit
						774ac9b9bd
					
				
					 1 changed files with 26 additions and 0 deletions
				
			
		
							
								
								
									
										26
									
								
								varo/src/main/java/de/cliffbreak/varo/uitls/WebUtils.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								varo/src/main/java/de/cliffbreak/varo/uitls/WebUtils.java
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
package de.cliffbreak.varo.uitls;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.HttpURLConnection;
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
 | 
			
		||||
public class WebUtils {
 | 
			
		||||
 | 
			
		||||
    public static String GET(String url) throws MalformedURLException, IOException {
 | 
			
		||||
        HttpURLConnection connection = ((HttpURLConnection) (new URL(url)).openConnection());
 | 
			
		||||
        connection.setRequestMethod("GET");
 | 
			
		||||
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 | 
			
		||||
        String inputLine;
 | 
			
		||||
        StringBuffer content = new StringBuffer();
 | 
			
		||||
        while ((inputLine = in.readLine()) != null) {
 | 
			
		||||
            content.append(inputLine);
 | 
			
		||||
        }
 | 
			
		||||
        in.close();
 | 
			
		||||
        connection.disconnect();
 | 
			
		||||
        return content.toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue