Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package sandeep.kb.android.remote.utils; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.json.JSONObject; import org.openqa.selenium.io.IOUtils; /** * A utility class having commonly used methods * * @author Sandeep */ public class Utils { public static void sleep(long millis) { try { Thread.sleep(millis); } catch (InterruptedException ex) { Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex); } } public static void log(String name, String string) { Logger.getLogger(name).log(Level.INFO, string.toString()); } public static String readDataFromFile(String path) { String data = null; try { InputStream fileStream = Utils.class.getResourceAsStream(path); data = IOUtils.readFully(fileStream); } catch (IOException ex) { Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex); } return data; } }