Simple HTML Form Parser which parses the given string of HTML and returns Map of (name,value) pair of form's input attribute.
CODE : MyHtmlFormParser class
String SPACE =" ";
String [] words = input.split(SPACE);
Map<String,Integer> frequency = new HashMap<String,Integer>();
for (String word:words){
Integer f = frequency.get(word);
frequency.put(word,f+1);
}
frequency.get(word);
The code to ping a URL from java application is as follows :
With response time:
public static boolean isThisApplicationRunning(final Context context, final String appPackage) {
if (appPackage == null) {
return false;
}
final ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningAppProcessInfo> runningAppProcesses = manager.getRunningAppProcesses();
for (final RunningAppProcessInfo app : runningAppProcesses) {
if (appPackage.equals(app.processName)) {
return true;
}
}
return false;
}
public static boolean isThisServiceRunning( final Context context, final String servicePackageName) {
final ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (final RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (servicePackageName.equals(service.service.getClassName())) {
return true;
}
}
return false;
}
String path = Test.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");