Archive for December 31st, 2005

Posted on Dec 31st, 2005

Two years ago I blogged about a similar subject. I discussed the advantages of Internet Explorer (IE) over Mozilla and other web browsers in a corporate environment. I concluded that IE is by far the better choice. Recently we deployed about 250 new computers and so I considered this question again. Now, Firefox is the main rival of IE. The decision was not so easy this time, but IE won again in the end.

I am using Firefox myself for a quite while and I really like this web browser. However, when it comes to the question of switching to a new web browser in a corporate network, other arguments have to be considered.

Let’s discuss them step by step:

1. IE is a part of the operating system

This basically means that the administrators don’t have much further work after Windows is installed. If you have hundreds or even thousands computers to manage, this is already a very big advantage of the IE. You need some good arguments for deploying an extra browser, if there is already one installed on your machines. Some nice plugins are certainly not enough. One often-mentioned argument is security. I don’t want to discuss this issue here, but if you are really convinced that Firefox is more secure than IE, this might be such an argument.

2. Roaming Profiles

I mention this point here because I discussed it in my German blog two years ago. Firefox, like IE, does store its user-settings, bookmarks, etc., in the user profile, which means that one can now work with roaming profiles. Thus, users can logon on different machines in the network and will always find their own bookmarks. This is a major improvement compared to the rivals of IE two years ago.

3. Central Management

Probably the most significant advantage of IE is that you can centrally manage it using Group Policies. You always want to configure all applications as homogenous as possible in a big network. Sometimes it is necessary to change the settings of all web browsers in your company. For example you might want to change the start page of all browsers or enable/disable certain functions or add new bookmarks, etc.

There is an Open Source Project called Firefox ADM working on this feature for Firefox. They started a year ago and reached version 0.4 now. As long as there is no version 1.0, I would be cautious in using this feature in a productive environment. I had a quick look at the ADM files. It has fewer possibilities in comparison to IE, that’s my first impression. I plan to have a closer look at Firefox ADM again in the near future and will post my findings in my weblog.

4. Patch Management

I have already mentioned the security issue before. We all know that not only Microsoft programmers but also Open Source coders make mistakes. No web browser will ever exist without security holes. Some Firefox advocates say that security patches are supplied at faster pace than in IE. It is a difficult question to answer, and I don’t want to discuss this topic here.

However, when it comes to security in a corporate network, the main question should be how fast and how easy you can patch all your computers. The larger your network is, the more important this point gets. Firefox has an integrated update mechanism which is quite useful for private users, but doesn’t help much in a corporate environment. Because of security issues, normal users are usually not allowed to install software on their computers which also means that they can’t install patches.

If you are a Windows administrator, you probably know that Microsoft offers a free patch management solution. WSUS (Windows Software Update Services) certainly is a great tool. Of course, you can patch IE using WSUS. There are third party patch management solutions which also support Firefox though. If you are already using such a program, patch management might not be something that troubles you too much when you have to decide which web browser to use in your network. However, if you are also using WSUS, patching IE might be less time consuming than patching Firefox with a third party solution. At least, this is true for patch management solutions I’ve seen.

5. Many applications are dependent on the IE

There are many desktop applications which use the rendering engine of IE to display HTML files. There also server-based applications which need an IE and won’t work with just another browser. With the success of Firefox at least the latter’s argument doesn’t hold much anymore since many webmasters don’t want to lock out this large clientele.

However, there are still many desktop apps which are IE dependent. Some of them aren’t dependent on the rendering engine of IE, but integrate themselves in the user interface of IE. Adobe Arcobat is such an application for example. Even if you don’t have one of them in your company now, you’ll never know if this might not change in the future. The point is that if you need IE anyway, why you should deploy and support another browser in your network?

Conclusion

The advantages of the IE are mainly founded in its tight integration with Windows. Firefox has to run on other operating systems, too. Hence, all features should work on all systems not only on Windows boxes. That’s why I’m not expecting too many improvements in this field in the near future. Although projects like Firefox ADM show that better integration is doable and that some Open Source programmers recognized this problem.

All in all, I’m still a Firefox fan, but wouldn’t recommend it for corporate use in larger networks. There are exceptions of course: If all your desktops use Linux or Mac OS. But if you have Windows desktops, the only reason I could think of, is that you really need a certain feature of Firefox which you is not available in IE.

Michael Pietroforte is working as a system administrator for more than 15 years. For several years he is now leading an IT department. He also published articles on several computer journals. His weblog http://4sysops.com/ discusses useful tools for Windows and Linux system administrators.

Posted on Dec 31st, 2005

Handling character strings in Java is supported through two final classes: String and StringBuffer. The String class implements immutable character strings, which are read-only once the string has been created and initialized, whereas the StringBuffer class implements dynamic character strings. All string literals in Java programs, are implemented as instances of String class. Strings in Java are 16-bit Unicode.

Note : In JDK 1.5+ you can use StringBuilder, which works exactly like StringBuffer, but it is faster and not thread-safe

The easiest way of creating a String object is using a string literal:

String str1 = "I cant be changed once created!";

A string literal is a reference to a String object. Since a string literal is a reference, it can be manipulated like any other String reference. i.e. it can be used to invoke methods of String class.

For example,

Int myLength = “Hello world”.length();

The Java language provides special support for the string concatenation operator ( + ), which has been overloaded for Strings objects. String concatenation is implemented through the StringBuffer class and its append method.

For example,

String finalString = “Hello” + “World”

Would be executed as

String finalString = new StringBuffer().append(“Hello”).append(“World”).toString();

The Java compiler optimizes handling of string literals. Only one String object is shared by all string having same character sequence. Such strings are said to be interned, meaning that they share a unique String object. The String class maintains a private pool where such strings are interned.

For example,

String str1=”Hello”;

String str2=”Hello”;

If(str1 == str2)

System.out.println(“Equal”);

Would print Equal when run.

Since the String objects are immutable. Any operation performed on one String reference will never have any effect on other references denoting the same object.

Constructors

String class provides various types of constructors to create String objects. Some of them are,

String()

Creates a new String object whose content is empty i.e. “”.

String(String s)

Creates a new String object whose content is same as the String object passed as an argument.

Note: Constructor creates a new string means it does not intern the String. Interned String object reference can be obtained by using intern() method of the String class

String also provides constructors that take byte and char array as argument and returns String object.

String equality

String class overrides the equals() method of the Object class. It compares the content of the two string object and returns the boolean value accordingly.

For example,

String str1=”Hello”;

String str2=”Hello”;

String str3=new String(”Hello”) //Using constructor.

If(str1 == str2)

System.out.println(“Equal 1”);

Else

System.out.println(“Not Equal 1”);

If(str1 == str3)

System.out.println(“Equal 2”);

Else

System.out.println(“I am constructed using constructor, hence

not interned”);

If( str1.equals(str3) )

System.out.println(“Equal 3”);

Else

System.out.println(“Not Equal 3”);

The output would be,

Equal 1

Not Equal 2

Equal 3

Note that == compares the references not the actual contents of the String object; Where as equals method compares actual contents of two String objects.

String class also provides another method equalsIgnoreCase() which ignores the case of contents while comparing.

Apart from these methods String class also provides compareTo methods.

int compareTo(String str2)

This method compares two Strings and returns an int value. It returns value 0, if this string is equal to the string argument a value less than 0, if this string is less than the string argument

a value greater than 0, if this string is greater than the string argument

int compareTo(Object object)

This method behaves exactly like the first method if the argument object is actually a String object; otherwise, it throws a ClassCastException.

String Manipulations

Reading characters from String:

char charAt(index i)

Returns char at specified index. An index ranges from 0 to length() -1.

Searching characters in String

String class provides indexOf method which searches for the specified character inside the string object. This method has been overloaded. If the search is successful, then it returns the index of the char otherwise -1 is returned.

int indexOf(int c)

Returns the index of first occurrence of the argument char.

int indexOf(int c, int fromIndex)

Finds the index of the first occurrence of the argument character in a string, starting at the index specified in the second argument.

int indexOf(String str)

Finds the start index of the first occurrence of the substring argument in a String.

int indexOf(String str, int fromIndex)

Finds the start index of the first occurrence of the substring argument in a String, starting at the index specified in the second argument.

The String class also provides methods to search for a character or string in backward direction. These methods are given below.

int lastIndexOf(int ch)

int lastIndexOf(int ch, int fromIndex)

int lastIndexOf(String str)

int lastIndexOf(String str, int fromIndex)

Replacing characters in String

The replace method of String can be used to replace all occurrences of the specified character with given character.

String replace(char oldChar, int newchar)

Getting substrings

String class provides substring method to extract specified portion of the given String. This method has been overloaded.

String substring(int startIndex)

String substring(int startIndex, int endIndex)

Note: A new String object containing the substring is created and returned. The original String won’t be affected.

If the index value is not valid, a StringIndexOutOfBoundsException is thrown.

Conversions

String class provides set of static overloaded valueOf method to convert primitives and object into strings.

static String valueOf(Object obj)

static String valueOf(char[] character)

static String valueOf(boolean b)

static String valueOf(char c)

static String valueOf(int i)

static String valueOf(long l)

static String valueOf(float f)

static String valueOf(double d)

Manipulating Character Case

String class provides following methods to manipulate character case in String.

String toUpperCase()

String toUpperCase(Locale locale)

String toLowerCase()

String toLowerCase(Locale locale)

Note : Original String object is returned if none of the characters changed, otherwise new String object is constructed and returned.

Miscellaneous methods

String trim()

This method removes white space from the front and the end of a String.

int length()

Returns length of the String.

String intern()

This method returns interned String object, if already present in the String pool. Otherwise this String is added into the pool, and then interned reference is returned.

Rahim Vindhani
Application Develper [Application Development & Webservices]
IBM Global Services, pune, India
email: rahim.vindhani@gmail.com
web: http://www.javadeveloper.co.in