YouSendIt
Technorati Tags: YouSendIt
Blogs linking to this article
Easy practical tips, tricks, tools
public class EnForIf we analyse the for code, then the following happens:
{
public static void main(String[] args)
{
String[] cities =
{"Pune", "Mumbai", "Bangalore", "Hyderabad"};
for (String name : cities)
{
System.out.println(name);
}
}
}
greetings = HelloThe same contents would be there in the file MessagesBundle_en_US.properties. To create the .properties files in other languages, I am making use of the free, online Free2Professional Site.
welcome = Welcome to India
greetings = Hallo(b) Define the Locale The Locale object identifies a particular language and country. The program gets the Language and Country code from the command line. Thus,
welcome = Willkommen in Indien
String lang = new String(args[0]);(c) Create a Resource Bundle: The ResourceBundle objects contain locale-specific objects. It is created as:
String country = new String(args[1]);
Locale cLocale = new Locale(lang, country);
ResourceBundle msg =(d) Fetch the Text from the ResourceBundle: To retrieve the message identified by the welcome key, you invoke getString as follows:
ResourceBundle.getBundle("MessagesBundle", cLocale);
String msg = msg.getString("welcome");Well, that's all that's required. Here's the full code:
import java.util.*;To run the program, open a DOS window and type:
public class InternationalizationEx
{
public static void main(String[] args)
{
String lang, country;
Locale cLocale;
ResourceBundle msg;
if (args.length != 2)
{
lang = new String("en");
country = new String("US");
}
else
{
lang = new String(args[0]);
country = new String(args[1]);
}
cLocale = new Locale(lang, country);
msg = ResourceBundle.getBundle("MessagesBundle", cLocale);
System.out.println(msg.getString("greetings"));
System.out.println(msg.getString("welcome"));
}
}
java InternationalizationEx de DENote: Ensure that the three .properties files and the .java program are in the same folder.
import static java.lang.Math.*;
import static java.lang.System.out;
public class MyMath5
{
public static void main(String[] args)
{
// returns a double between 0.0 thro' (but not
// including) 1.0
double r1 = random();
int r2 = (int) (random() * 5);
out.println("r1 = " + r1);
out.println("r2 = " + r2);
// Returns the absolute value of the argument
int x = abs(-240);
double d = abs(240.45);
out.println("x = " + x);
out.println("d = " + d);
// Returns an int or long (depending on whether
// the argument is foat or double)
// rounded to the nearest integer value
int p = round(-24.8f);
long q = round(24.45);
out.println("p = " + p);
out.println("q = " + q);
// Returns a value that is minimum of two values
int c = min(243, 240);
double dd = min(90876.5, 90876.49);
out.println("c = " + c);
out.println("dd = " + dd);
// Returns a value that is maximum of two values
int e = max(243, 240);
double f = max(90876.5, 90876.49);
out.println("e = " + e);
out.println("f = " + f);
}
}
public class BoxingUnBoxingBoxing/Unboxing saves us the bother of converting from a primitive to it's wrapper and vice-versa. This feature is definitely a time-saver.
{
public static void main(String[] args)
{
// Boxing
int var = 10;
Integer wInt = var;
int result = var * wInt;
System.out.println("Value of result = " + result);
// Unboxing
int conv = wInt;
if (conv < 100)
System.out.println("True");
}
}
We do allow modification of our code to comply with W3C HTML and XHTML standards. In order to make your code compliant, you'll need to make the following changes to the AdSense for search code:
1. Remove the closing </input> and </image> tags
2. Add an additional closing '/' to the end of the opening html tags for <input> and <image>. This should occur for all 'image' and 'input' tags.
Please note that the AdSense for search code may only be modified as specified above. Our program policies do not permit any additional modifications. We appreciate your understanding.
I too use the simple, practical tracking tool, Extreme Tracking. I have been blogging for about 20 days only but I can see some trends emerging."This blog is not so big that I should attempt to consider analyzing web trends based on my site statistics. I came across several important indicators of my traffic so it is my humble effort to share them with you. We all have some site traffic tracker to check for how many visitors we get everyday and what is the trend. Other tracking indicators help you to fix your site for better optimization."
I needed to do something about this and started searching on Google about 'Writer's Block'. The search gave me a long list of articles on this topic and one particular article by Lisa R. Cohen caught my eye. She mentions 'Write about Writer's Block' and hence this post! I found her site very informative.Is it lack of Time? Not true. I spend hours going thro' the different blog feeds (170 to date) I have subscribed thro' Bloglines; surely I can devote some time from this to write.
Do I need a vacation? Again, not true. Very recently, I had taken a break from the daily grind.
Health problem? NO. Touch wood, I am in the pink of health!