[Java] How To Check if a String is a Valid Number?

If you are someone new to Java and would like to check if a String is a valid number or not, this post will help you get answer to your question.

Below is the coded snippet with explanation for checking out if a string is a valid number. The below mentioned code is written in Java.

In the below mentioned code snippet, i declared an integer called isThisANumber , this integer will be used to save the parsed Integer. Static method parseInt( ) of the Integer class has been used to attempt to convert the string parameter into an Integer. In case if the string is not a valid integer and throws up parsing issues while converting, NumberFormatException is thrown.

int isThisANumber = 0;
try
{
isThisANumber = Integer.parseInt(someStringToTest); 
}
catch (NumberFormatException nfe)
{
System.out.println("This string is not a valid number."); //Oops..not a valid int
}

 

You can also follow me on Twitter at http://twitter.com/vaibhav1981

Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.

SweetHome 3D lets you design the interior of your House

Earlier i wrote about an interesting web based service called DesignMyRoom, which lets you design and do interiors for your room, today, in this post i will introduce you to a stand alone software called SweetHome 3D which is a free interior design application that helps you place your furniture on a house 2D plan, with a 3D preview.

SweetHome 3D is aimed at people who want to design their interior quickly, whether they are moving or they just want to redesign their existing home. Numerous visual guides help you draw the plan of your home and layout furniture. You may draw the walls of your rooms upon the image of an existing plan, and then, drag and drop furniture onto the plan from a catalog organized by categories. Each change in the 2D plan is simultaneously updated in the 3D view, to show you a realistic rendering of your layout.

Sweet Home 3D may be run on Windows, Mac OS X 10.4 / 10.5, Linux and Solaris, and is translated in 11 different languages.

Sweet Home 3D

Image: Sweet Home 3D

Depending on your system, use the following instructions to download Sweet Home 3D and install it:

Windows: Download http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-1.5-windows.exe (25 MB), run the downloaded installation program, and follow the instructions from the setup wizard.

Mac OS X: Download

http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-1.5-macosx.dmg (11 MB), double-click on the downloaded file and run Sweet Home 3D application found in the opened folder. To install Sweet Home 3D, drag and drop the application in the folder of your choice.

Linux: Download http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-1.5-linux-x86.tgz (40 MB), uncompress the downloaded file and run SweetHome3D application found in the uncompressed directory. To install Sweet Home 3D, move the uncompressed directory to one of your choice.

Some interesting features of SweetHome 3D worth mentioning

1.) You can import your home plan blueprint to get started faster with SweetHome 3D. 

2.) Based on the imported plan, create walls with a click of a button.

3.) Adjust the 3D view of the plan at any time.

4.) Enlarge Walls and also add, adjust and modify Windows and Doors to them. Wide variety of Doors and Windows are available in the catalog, all you need to do is select them from the catalog.

5.) Add Furniture, visit Home layout. 

In short, SweetHome 3D lets you become an architect of your house and lets you become an interior designer of your home.

You can also follow me on Twitter at http://twitter.com/vaibhav1981

Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.

[Adsense] Prevent your Competitors Ads from Showing up in your Website

We often hear about scenarios wherein Ads of Competing businesses get shown up as part of the Adsense Ads showed on your website. This certainly is not the best way of growing your business, However, this can be prevented by adding specific setup rules in your Adsense account. This post describes a step by step process for setting up Competitive Ad Filter in Google Adsense.

If you are an Adsense Publisher and would like to prevent your competitor’s ads from being shown on your website as part of the Google Adsense Ads which are dynamically showed to your end users based on the keywords and other related terms, follow the steps below. (Click on the images for a detailed view).

1.) Login to your Adsense Account.

Adsense Setup Link enables you to setup Google Adsense for your site.

Adsense Setup Link enables you to setup Google Adsense for your site.

2.) Click on the tab which says Adsense Setup.

3.) Once inside Adsense Setup, click on the link which says Competitive Ad Filter. 

Setting up Adsense to prevent Competitor's ads from being shown in your site.

Setting up Adsense to prevent Competitor

The Competitive Ad Filter enables you to block specific ads, such as competitors’ ads, from appearing on your pages. Entering a more general URL will block a wider range of ads; entering a more specific URL will block a smaller range of ads. For example, by entering a top level domain such as “example.com”, you’ll also block all ads that link to any sub-directories of that domain, like “forums.example.com”. Review the examples below to learn how you can create filters that will block only the range of ads you want.

Enter the URLs of your comptetitor's website or business

Enter the URLs of your comptetitor

4.) Specify URL’s of your competitors website ( Ads pointing to these URL’s shall then be filtered before being shown to your site’s end visitors) for various Adsense services like Adsense for Content, Adsense for Search and Adsense for Feeds. Click on Save Changes once done. 

You have now setup your Adsense account to filter your competitors ads before being shown to your site visitors. 

Also, as a general tip, never click on the ads on your Own Website. Google definitely can figure out if you are clicking on your own Adsense Ads.

You can follow me on Twitter at http://twitter.com/vaibhav1981

Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.

[How-To] Add Custom Watermark to your images with PicMarkr.

You already know about the various services from where you can get Free images for your Blog. However, if you are someone who wants to watermark his images for various reasons; PickMarkr is the service to go for.

PicMarkr is a free to use service which can be used to apply Watermark your images and download them for usage for free.

PicMarkr

PicMarkr

In order to watermark your images, follow the steps below

 

Steps for Watermarking Images

Steps for Watermarking Images

1.) Upload Photos you wish to Watermark.

2.) Choose the Watermark to be applied. You can choose from Text, Image or Tiled options.

3.) Get your Watermarked images. 

What are some interesting features about PicMarkr?

  • You can either upload your pictures or grab them from your Flickr account.
  • Apply Watermark and process multiple images in batches.
  • The best of all, you dont need to install or download anything. All you need to do is select your images, watermark option and apply the watermark for processing.

All in all, PickMarkr is a great service with ease of use, which lets you WaterMark your images for free. Do give PicMarkr a try.

You can follow me on Twitter at http://twitter.com/vaibhav1981

Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.

[How-To] Make your USB Disks Perform Faster

This simple hack is particularly useful if you leave your USB Hard Disk permanently connected to your laptop or PC. If you are sure that the USB drive will always be connected, it can be configured to perform faster. 

Follow the steps below to configure your USB Drive to perform faster. 

1.) In Control Panel, click on System. Under System dialog, click on Hardware and then Device Manager. 

2.) Under Device Manager, expand the Disk Drives section. 

Optimizing USB Disks for Performance

Optimizing USB Disks for Performance

3.) Select your Drive and right click to open Properties.

Performance Tuning your USB Drive

Performance Tuning your USB Drive

4.) Under Policies, select Optimize for Performance. Click OK.

That is it. You are done. For a USB drie, when you enable Optimize for Performance, it is enabled for write caching which in turn leads to beter speed and therefore better performance.

You can also follow me on Twitter at http://twitter.com/vaibhav1981

Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.