Firefox 3 Mac VS Safari Mac

I realized only now that my Safari browser is already version 3. My friend asked me which of the two is faster in Mac OS. No matter what, I still prefer Firefox 3 (beta) over Safari v3. I just see Firefox’s lightweightness-ness when I run the browser. The look and feel for Firefox 3 is blended alright. Looks like any ordinary Mac application. Safari 3 may be an ok application but I don’t like its UI design. My friend also mentioned a problem in Firefox 3’s fonts’ anti-aliasness but I never saw any differences in my Mac OS. I noticed Firefox 3 doesn’t crash as much as its previous version does so good job with this even though it’s still in Beta. If you want to use Firefox 3 for Windows, you won’t have any problems with the UI as it looks exactly the same as the Mac version. If you’re into wanting useful little applications for use within your browser, Firefox has lots of add-ons and more than Safari. But the existing add-ons for Firefox’s previous version are not compatible with the Beta version yet though I’m pretty sure that once Firefox rolls out with its release version, its add-ons will then be compatible. My choice with the browser wars even in the Mac OS, is still Firefox. Safari Mac is a distant second while IE Mac is non-existent.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...

Java Encrypt String using MD5

To get the md5 hash equivalent of a String, use this method. Remember, that there’s no way to undo an md5 hash conversion.

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
 
public static String hex(byte[] array) {
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < array.length; ++i) {
    sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).toUpperCase().substring(1,3));
  }
  return sb.toString();
}
 
 
public static String md5(String message) { 
  try { 
    MessageDigest md = MessageDigest.getInstance("MD5"); 
    return hex (md.digest(message.getBytes("CP1252"))); 
  } catch (NoSuchAlgorithmException e) { } catch (UnsupportedEncodingException e) { } 
  return null;
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(1 votes, average: 5.00 out of 5)
 Loading ...

Java Get Response Body From Stream

This method gets the response body of a stream in every detail. I had an experience retrieving the contents of an HTML page and the output was messy. The line breaks were not correct as in the original source. To fix this, use the method below. It returns the response body as a String and its output is the same as when you do a view source code of the HTML page.


import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;

public static String getResponseBodyFromStream(InputStream is) {
  String str = “”;
  try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[128];
    int size = 0;

    while ((size = is.read(buffer)) > 0) {
      baos.write(buffer, 0, size);
    }
    str = new String(baos.toByteArray());
  } catch (IOException ioe) { }
  return str;
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...

Java Get Number Of Occurences of String

This method returns the number of occurences of the search keyword in the entire string. Method takes two parameters, the string to be searched and the second one is the string to search for.


public static int getCountIndexOf(String string, String search) {
  String str = string;
  String ch = search;
  int count = 0 ;
  int pos = -1 ;
  while ((pos = str.indexOf(ch, pos + 1)) > -1) count++ ;

  return count;
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...