Generates Random Integers in a Specific Range

Generates Random Integers in a Specific Range

import java.util.Random;

/** Generate random integers in a certain range. */
public final class RandomRange {
 
  public static final void main(String... aArgs){
    log("Generating random integers in the range 1..10.");
   
    int START = 1;
    int END = 10;
    Random random = new Random();
    for (int idx = 1; idx <= 10; ++idx){
      showRandomInteger(START, END, random);
    }
   
    log("Done.");
  }
 
  private static void showRandomInteger(int aStart, int aEnd, Random aRandom){
    if (aStart > aEnd) {
      throw new IllegalArgumentException("Start cannot exceed End.");
    }
    //get the range, casting to long to avoid overflow problems
    long range = (long)aEnd - (long)aStart + 1;
    // compute a fraction of the range, 0 <= frac < range
    long fraction = (long)(range * aRandom.nextDouble());
    int randomNumber =  (int)(fraction + aStart);  
    log("Generated : " + randomNumber);
  }
 
  private static void log(String aMessage){
    System.out.println(aMessage);
  }
}


An example run of this class:
Generating random integers in the range 1..10.
Generated : 9
Generated : 3
Generated : 3
Generated : 9
Generated : 4
Generated : 1
Generated : 3
Generated : 9
Generated : 10
Generated : 10
Done.
Generates Random Floating Point Numbers

Generates Random Floating Point Numbers

import java.util.Random;

/**
 Generate pseudo-random floating point values, with an
 approximately Gaussian (normal) distribution.

 Many physical measurements have an approximately Gaussian
 distribution; this provides a way of simulating such values.
*/
public final class RandomGaussian {

  public static void main(String... aArgs){
    RandomGaussian gaussian = new RandomGaussian();
    double MEAN = 100.0f;
    double VARIANCE = 5.0f;
    for (int idx = 1; idx <= 10; ++idx){
      log("Generated : " + gaussian.getGaussian(MEAN, VARIANCE));
    }
  }
 
  private Random fRandom = new Random();

  private double getGaussian(double aMean, double aVariance){
    return aMean + fRandom.nextGaussian() * aVariance;
  }

  private static void log(Object aMsg){
    System.out.println(String.valueOf(aMsg));
  }
}


An example run of this class:
Generated : 99.38221153454624
Generated : 100.95717075067498
Generated : 106.78740794978813
Generated : 105.57315286730545
Generated : 97.35077643206589
Generated : 92.56233774920052
Generated : 98.29311772993057
Generated : 102.04954815575822
Generated : 104.88458607780176
Generated : 97.11126014402141
Generate random numbers

Generate random numbers

import java.util.Random;

/** Generate 10 random integers in the range 0..99. */
public final class RandomInteger {
 
  public static final void main(String... aArgs){
    log("Generating 10 random integers in range 0..99.");
   
    //note a single Random object is reused here
    Random randomGenerator = new Random();
    for (int idx = 1; idx <= 10; ++idx){
      int randomInt = randomGenerator.nextInt(100);
      log("Generated : " + randomInt);
    }
   
    log("Done.");
  }
 
  private static void log(String aMessage){
    System.out.println(aMessage);
  }
}

Example run of this class:
Generating 10 random integers in range 0..99.
Generated : 44
Generated : 81
Generated : 69
Generated : 31
Generated : 10
Generated : 64
Generated : 74
Generated : 57
Generated : 56
Generated : 93
Done.
Sending Email through Gmail Server Using JavaServlets

Sending Email through Gmail Server Using JavaServlets

import java.io.*;
import java.net.*;

import java.util.Properties;
import javax.mail.AuthenticationFailedException;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.*;
import javax.servlet.http.*;

public class SendEmail extends HttpServlet {

 protected void processRequest(HttpServletRequest request,
                                  HttpServletResponse response)
                   throws IOException, ServletException {

        final String err = "/error.jsp";
        //final String succ = "/success.jsp";

        String from = "abc@gmail.com"    // Sender Email-Id
        String to = "xyz@gmail.com"     // Receiver Email-Id

System.out.println("mail : "+to);
        String subject = "Subject";          //Your Subject.
        String message = "Message"    Your Message

        String login = "abc@gmail.com";        //Sender Mail_Id
        String password = "xyx"; //Sender Mail Password

        try {
            Properties props = new Properties();
            props.setProperty("mail.host", "smtp.gmail.com");
            props.setProperty("mail.smtp.port", "587");
            props.setProperty("mail.smtp.auth", "true");
            props.setProperty("mail.smtp.starttls.enable", "true");

            Authenticator auth = new SMTPAuthenticator(login, password);

            Session session = Session.getInstance(props,auth);

            MimeMessage msg = new MimeMessage(session);
            msg.setText(message);
            msg.setSubject(subject);
            msg.setFrom(new InternetAddress(from));
            msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
            Transport.send(msg);

        } catch (AuthenticationFailedException ex) {
            request.setAttribute("ErrorMessage", "Authentication failed");

            RequestDispatcher dispatcher = request.getRequestDispatcher(err);
            dispatcher.forward(request, response);
            return;

        } catch (AddressException ex) {
            request.setAttribute("ErrorMessage", "Wrong email address");

            RequestDispatcher dispatcher = request.getRequestDispatcher(err);
            dispatcher.forward(request, response);
            return;
        } catch (MessagingException ex) {
           request.setAttribute("ErrorMessage", ex.getMessage());
       
            RequestDispatcher dispatcher = request.getRequestDispatcher(err);
            dispatcher.forward(request, response);
            return;
        }
            RequestDispatcher dispatcher = request.getRequestDispatcher("/success.jsp?email="+to);
            dispatcher.forward(request, response);
            return;
    }

    private class SMTPAuthenticator extends Authenticator {

        private PasswordAuthentication authentication;

        public SMTPAuthenticator(String login, String password) {
            authentication = new PasswordAuthentication(login, password);
        }

        protected PasswordAuthentication getPasswordAuthentication() {
            return authentication;
        }
    }

    protected void doPost(HttpServletRequest request,
                         HttpServletResponse response)
                   throws ServletException, IOException {
        processRequest(request, response);
    }

 
}

Java Date and Time

Java Date and Time

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class SimpleDateFormatExample {
public static void main(String[] args) {

Date curDate = new Date();

SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");

String DateToStr = format.format(curDate);
System.out.println(DateToStr);

format = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
DateToStr = format.format(curDate);
System.out.println(DateToStr);

format = new SimpleDateFormat("dd MMMM yyyy zzzz", Locale.ENGLISH);
DateToStr = format.format(curDate);
System.out.println(DateToStr);

format = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z");
DateToStr = format.format(curDate);
System.out.println(DateToStr);

try {
Date strToDate = format.parse(DateToStr);
System.out.println(strToDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
Output:

2014/12/19
19-12-2014 04:54:26
19 December 2014 India Standard Time
Fri, 19 Dec 2014 16:54:26 IST
Fri Dec 19 16:54:26 IST 2014


Java Program to print Circular (Spiral) Matrix

Question:

            Write a Program in Java to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input.

For example: if n = 4, then n*n = 16, hence the array will be filled as given below




Note: This program is also known as Spiral Matrix

Solution:

import java.io.*;


class Circular_Matrix

    {

        public static void main(String args[])throws IOException

        {

            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

            System.out.print("Enter the number of elements : ");

            int n=Integer.parseInt(br.readLine());



            int A[][]=new int[n][n];

            int k=1, c1=0, c2=n-1, r1=0, r2=n-1;



            while(k<=n*n)

                {

                    for(int i=c1;i<=c2;i++)

                    {

                        A[r1][i]=k++;

                    }



                    for(int j=r1+1;j<=r2;j++)

                    {

                        A[j][c2]=k++;

                    }



                    for(int i=c2-1;i>=c1;i--)

                    {

                        A[r2][i]=k++;

                    }



                    for(int j=r2-1;j>=r1+1;j--)

                    {

                        A[j][c1]=k++;

                    }



                 c1++;

                 c2--;

                 r1++;

                 r2--;

                }

 

            /* Printing the Circular matrix */

            System.out.println("The Circular Matrix is:");

            for(int i=0;i<n;i++)

                {

                    for(int j=0;j<n;j++)

                        {

                            System.out.print(A[i][j]+ "\t");

                        }

                 System.out.println();

                }

        }

    }

Working:



    
            We will take a variable ‘k’ which will begin with 1 and will do the work of filling. i.e. for every cell, it will increase by 1. The below given processes will repeat till the value of ‘k’ becomes ‘n*n’

C1 denotes the index of the column from where we have to begin. Hence its initial value will be 0.
C2 denotes the index of the column where we have to end. Hence its initial value will be ‘n-1′ (n is the size of the matrix).
R1 denotes the index of the row from where we have to begin. Hence its initial value will be 0.
R2 denotes the index of the row where we have to end. Hence its initial value will be ‘n-1′ (n is the size of the matrix).
The filling up of the matrix in circular fashion will consist of 4 different steps which will continue till the matrix is filled completely.

Step 1: We will fill the elements of Row 0 (R1), starting from Column 0 (C1) till ‘n-1′ (C2). The cells which will be filled are marked in the image above in yellow color.
The elements will be accessed as follows: A[R1][i], where ‘i’ will go from C1 to C2 (A[ ][ ] is the array)

Step 2: Now, we will fill the elements of Column ‘n-1′ (C2), starting from Row R1+1 till R2. The cells which will be filled are marked in the image above in grey color.
The elements will be accessed as follows: A[j][C2], where ‘j’ will go from R1+1 to R2 (A[ ][ ] is the array)

Step 3: Next we will fill the elements of Row ‘n-1′ (R2), starting from Column C2-1 till C1. The cells which will be filled are marked in the image above in green color.
The elements will be accessed as follows: A[R2][i], where ‘i’ will go from C2-1 to C1 (A[ ][ ] is the array)

Step 4: Now, we will fill the elements of Column C1, starting from Row R2-1 till R1+1. The cells which will be filled are marked in the image above in blue color.
The elements will be accessed as follows: A[j][C1], where ‘j’ will go from R2-1 to R1+1 (A[ ][ ] is the array)

The above 4 steps will now repeat with the inner matrix which is marked in white color in the above image. For the inner matrix,
C1 will increase by 1 i.e. it will be C1+1.
C2 will decrease by 1 i.e. it will be C2-1.
R1 will increase by 1 i.e. it will be R1+1.
R2 will decrease by 1 i.e. it will be R2-1.

The above processes will repeat till we have filled in ‘n*n’ values.
  
Output:



Add Your Name (or) Application to right click Of My Computer

Add Your Name (or) Application to right click Of My Computer

Caution.

As it   is related to Windows registry it   can be dangerous. So, Try this at  your own risk.

To write your name on right click application

Please follow the steps

1. Copy/ Paste the following code in Notepad And then Save it as  .reg


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Registry Editor]

@="Your name or Name of the Application"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Registry Editor\command]

@="Location of   the Application"

2. Now edit it and then Type your name In

Eample :

[HKEY_CLASSES_ROOT \CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Registry Editor]

@="AHK"

3.   If you want to get any application, once you click your name or name
Of   application

Then, type the location Of the application Which you want to open In :

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Registry Editor\command]

@="Location of   the Application"

For  example : 

C:\Program  Files\Yahoo! \Messenger\messenger.exe
That's it finally save it And then Run it
------------------------------------------------------------

To  add Application Control Panel

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSI D\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\ControlPanel\command]
@="rundll32.exe shell32.dll,Control_RunDLL"

To  add Application add/remove

[HKEY_CLASSES_ROOT \CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Add/Remove\command]
@="control appwiz.cpl"

To  add Application Reboot

[HKEY_CLASSES_ROOT \CLSI D\ {20D04FE0-3AEA-1069-A2D8-08002B30309D}\ shell\ [Reboot ] \ command]
@="shutdown -r -f -t 5"

To  add Application Shutdown

[HKEY_CLASSES_ROOT \CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ shell\[ Shutdown]\command]
@="shutdown -s -f -t 5"

Keyboard Shortcuts List for Windows 7 and Windows Vista



If you spend as much time in front of a computer as I do, learning a shortcut which can save a few seconds off a common task can be significant. Throw in the fact that I’m also a bit lazy… and it should explain why I’m always looking around for new Keyboard Shortcuts. The majority of Windows 

7 keyboard shortcuts remain the same from Windows Vista and XP (thank you for that Microsoft), so many of the shortcuts I’ve compiled in this post should look familiar. If you have a favorite I’ve missed or you find a new one however, please be sure to tell me about it in the comments so I can add it to the list! 

Windows 7 and Windows Vista Keyboard Shortcuts

Windows logo key:: Open or close the Start menu 

Windows logo key + Left Arrow Key:: Snap current window to left side of screen for side-by-side viewing 

Windows logo key + Right Arrow Key:: Snap current window to left side of screen for side-by-side viewing 

Windows logo key + Left Arrow 2x:: Snap current window left across multiple monitors for side-by-side viewing 

Windows logo key + PAUSE:: Display the System Properties dialog box 

Windows logo key + D:: Display the desktop 

Windows logo key + M:: Minimize all windows 

Windows logo key + SHIFT+M:: Restore minimized windows to the desktop 

Windows logo key + E:: Open Computer 

Windows logo key + F:: Search for a file or folder 

CTRL+Windows logo key + F:: Search for computers (if you are on a network) 

Windows logo key + L:: Lock your computer or switch users 

Windows logo key + R:: Open the Run dialog box 

Windows logo key + T:: Cycle through programs on the taskbar 

Windows logo key + TAB:: Cycle through programs on the taskbar by using Windows Flip 3-D 

CTRL+Windows logo key + TAB:: Use the arrow keys to cycle through programs on the taskbar 
by using Windows Flip 3-D 

Windows logo key + SPACEBAR:: Bring all gadgets to the front and select Windows Sidebar 

Windows logo key + G:: Cycle through Sidebar gadgets 

Windows logo key + U:: Open Ease of Access Center 

Windows logo key + X:: Open Windows Mobility Center 

Windows logo key + Any number key:: Open the Quick Launch shortcut that is in the position that 
corresponds to the number. For example, Windows logo key + 1 :: Launch the first shortcut in the 
Quick Launch menu. 

Windows Key + S:: OneNote Screen Clipping Tool (Requires OneNote) 

Windows Key + =:: Open Magnifier Tool 

General Keyboard Shortcuts

F1:: Display Help 
F2:: Rename the selected item 
F3:: Search for a file or folder 
F4:: Display the Address bar list in Windows Explorer 
F5– Refresh the active window 
F6:: Cycle through screen elements in a window or on the desktop 
F7:: Check Spelling in open document 
F10:: Activate the menu bar in the active program 
CTRL+A:: Select all items in a document or window 
CTRL+C:: Copy the selected item 
CTRL+X:: Cut the selected item 
CTRL+V:: Paste the selected item 
CTRL+Z:: Undo an action 
CTRL+Y:: Redo an action 
SHIFT+DELETE:: Delete the selected item without moving it to the Recycle Bin first (Outlook Tip 
also) 
SHIFT+F10:: Display the shortcut menu for the selected item 
Hold SHIFT when you insert a CD:: Prevent the CD from automatically playing 
CTRL+ESC:: Open the Start menu 
CTRL+SHIFT with an arrow key:: Select a block of text 
CTRL+SHIFT+ESC:: Open Task Manager 
CTRL+F4:: Close the active document (in programs that allow you to have multiple documents open 
simultaneously) 
CTRL+ALT+TAB:: Use the arrow keys to switch between open items 
CTRL+Mouse scroll wheel:: Change the size of icons on the desktop 
ALT+ESC:: Cycle through items in the order in which they were opened 
ALT+ENTER:: Display properties for the selected item 
ALT+F4:: Close the active item, or exit the active program 
ALT+SPACEBAR:: Open the shortcut menu for the active window 
ALT+UP ARROW:: View the folder one level up in Windows Explorer 
ALT+TAB:: Switch between open items 
ALT+SHIFT+TAB:: Switch between open items in reverse order 
Windows logo key + TAB:: Cycle through programs on the taskbar by using Windows Flip 3-D 
CTRL+Windows logo key + TAB:: Use the arrow keys to cycle through programs on the taskbar 
by using Windows Flip 3-D 
ESC:: Cancel the current task 
Internet Explorer Keyboard Shortcuts
CTRL+click:: Open links in a new tab in the background 
CTRL+SHIFT+click:: Open links in a new tab in the foreground 
CTRL+T:: Open a new tab in the foreground 
CTRL+TABor CTRL+SHIFT+TAB:: Switch between tabs 
CTRL+W:: Close current tab (or the current window if tabbed browsing is disabled) 
ALT+ENTER:: Open a new tab in the foreground from the Address bar 
CTRL+n{where n is a number between 1 and 8}Switch to a specific tab number 
CTRL+9:: Switch to the last tab 
CTRL+ALT+F4:: Close other tabs 
CTRL+Q:: Toggle Quick Tabs (thumbnail view) on or off 
ALT+M:: Open the Home menu 
ALT+R:: Open the Print menu 
ALT+J:: Open the RSS menu 
ALT+O:: Open the Tools menu 
ALT+L:: Open the Help menu 
F1:: Display Help 
F11:: Toggle between full-screen and regular views of the browser window 
TAB:: Move forward through the items on a webpage, the Address bar, or the Links bar 
SHIFT+TAB:: Move back through the items on a webpage, the Address bar, or the Links bar 
ALT+HOME:: Go to your home page 
ALT+RIGHT ARROW:: Go to the next page 
ALT+LEFT ARROWor BACKSPACE:: Go to the previous page 
SHIFT+F10:: Display a shortcut menu for a link 
CTRL+TABor F6:: Move forward through frames and browser elements (only works if tabbed 
browsing is disabled) 
CTRL+SHIFT+TAB:: Move backward between frames (only works if tabbed browsing is disabled) 
CTRL+F:: Find on this page 
F5:: Refresh the current webpage 
CTRL+F5:: Refresh the current webpage, even if the time stamp for the web version and your 
locally stored version are the same 
ESC:: Stop downloading a page 
CTRL+O:: Open a new website or page 
CTRL+N:: Open a new window 
CTRL+W:: Close the current window (if you only have one tab open) 
CTRL+S:: Save the current page 
CTRL+P:: Print the current page or active frame 
CTRL+I:: Open Favorites 
CTRL+H:: Open History 
CTRL+J:: Open Feeds 
ALT+P:: Open the Page menu 
ALT+T:: Open the Tools menu 
ALT+H:: Open the Help menu 
Dialog box keyboard shortcuts
CTRL+TAB:: Move forward through tabs 
CTRL+SHIFT+TAB:: Move back through tabs 
TAB:: Move forward through options 
SHIFT+TAB:: Move back through options 
ALT+underlined letter:: Perform the command (or select the option) that goes with that letter 
ENTER:: Replaces clicking the mouse for many selected commands 
SPACEBAR:: Select or clear the check box if the active option is a check box 
Arrow keys:: Select a button if the active option is a group of option buttons 
F1:: Display Help 
F4:: Display the items in the active list 
BACKSPACE:: Open a folder one level up if a folder is selected in the Save As or Open dialog box 
Windows Sidebar keyboard shortcuts
Windows logo key + SPACEBAR:: Bring all gadgets to the front and select Sidebar 
Windows logo key +G:: Cycle through Sidebar gadgets 
TAB:: Cycle through Sidebar controls 
Windows Explorer keyboard shortcuts
END:: Display the bottom of the active window 
HOME:: Display the top of the active window 
F11:: Maximize or minimize the active window 
CTRL+N:: Open a new window 
CTRL+Mouse scroll wheel:: Change the size and appearance of file and folder icons 
NUM LOCK+ASTERISK (*) on numeric keypad:: Display all subfolders under the selected folder 
NUM LOCK+PLUS SIGN (+) on numeric keypad:: Display the contents of the selected folder 
NUM LOCK+MINUS SIGN (-) on numeric keypad:: Collapse the selected folder 
LEFT ARROW:: Collapse the current selection (if it is expanded), or select the parent folder 
ALT+D:: Select the Address bar 
ALT+LEFT ARROW:: View the previous folder 
ALT+RIGHT ARROW:: View the next folder 
RIGHT ARROW:: Display the current selection (if it is collapsed), or select the first subfolder 
Keyboard Shortcuts you will never use!
Left ALT+left SHIFT+PRINT SCREEN(or PRTSCRN) :: Turn High Contrast on or off 
Left ALT+left SHIFT+NUM LOCK:: Turn Mouse Keys on or off 
SHIFT five times:: Turn Sticky Keys on or off 
Hold NUM LOCK for five seconds:: Turn Toggle Keys on or off 
Windows logo key +U:: Open the Ease of Access Center 
SHIFT with any arrow key:: Select more than one item in a window or on the desktop, or select 
text within a document 
CTRL with any arrow key+SPACEBAR:: Select multiple individual items in a window or on the 
desktop 
CTRL+RIGHT ARROW:: Move the cursor to the beginning of the next word 
CTRL+LEFT ARROW:: Move the cursor to the beginning of the previous word 
CTRL+DOWN ARROW:: Move the cursor to the beginning of the next paragraph 
CTRL+UP ARROW:: Move the cursor to the beginning of the previous paragraph
Some Tips And Tricks in Windows

Some Tips And Tricks in Windows

1.TRICK TO CREATE FOLDERS WITHOUT NAME

=>Click on a FOLDER
=>Right click and goto rename option
=>Delete the old name
=>Pressing ALT key type 0160
=>Now press enter
=>You have created a folder without name

2.TRICK TO ADD YOUR NAME IN TASK BAR
GOTO

=>Start
=>Control Panel
=>Regional & Language Options
Customize
=>Time
=>AM Symbol
=>Enter your name

Thats it,your name is added to your Task Bar

3.TRICK TO CREATE A AUTORUN CD
=>Open notepad and type
[autorun]
OPEN=setup.exe
ICON=iconname.ico
=>save as autorun.inf on the desktop

Write ur CD with the autorun file, ur desired icon for the CD & the setup file.
iconname.ico is the name of the icon file which is desired for ur CD. =>Setup.exe is the name of the
setup which u want to make it autorun.

4.TRICK TO CHANGE THE INTERNET EXPLORER TITLE

Follow these simple steps

1)=>Go to Start
2)=>Type Regedit
3)Go to
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Window Title
4)Enter what you want appear in the title bar
eg:YOUR NAME
That’s it YOUR NAME will be displayed.

5.TRICK TO CLEAN RAM WITHOUT SOFTWARE
=>To clean ur RAM without software
=>Open notepad & type FREEMEM=SPACE(64000000)
=>Save it as ram.vbs and close it
=>Now run the script by double click on ti
=>now your pc work fast

6.TRICK TO DISABLE AUTOPLAY OF PENDRIVE
Disable autoplay of pendrive to avoid virus activation:
go to run

=>Run
=>Type gpedit.msc
=>Computer configuration
=>Administrative Templates
=>System
(In the Right side)
=>Go to Turn off Autoplay
=>Enable
=>All drives
7.TRICK TO FIX CORRUPTED FILES IN WINDOWS XP
=>Load XP cd into cd drive
=>Go to Run
=>Type sfc/scannowok
=>THEN copy and paste the lost file from cd

8.TRICK TO CONVERT TEXT INTO VOICE

A hidden trick to convert your text to voice without any software.

=>Try out this go to Run type
=>control speech
=>write any text & speech it

9.TRICK TO OPERATE PC WITHOUT MOUSE

=>Here is a simple trick to operate COMPUTER without MOUSE
PRESS the left
SHIFT+ALT+NumLock+ok
Now you can use your number keys to act as mouse
Note:It will not disable your mouse
To return back to previous state again press these combination keys together.

10.TRICK TO SHUTDOWN PC 100 TIMES FASTER
=>Press ctrl+alt+del
=>open task Manager
=>click the shutdown Tab.
=>While holding ctrl key,
=>Press TURN OFF.
with this simple trick you can shut down your pc 100 times faster.

10 Awesome Google Search Tricks.....


You may be spending hours in searching with Google.So learn some Google search hacks to get effective search results.

1. Identify Local  Time  for Any City  in the World using Google
    If you want to know current local time in a particular city, use the following method. To see the current           local TIME in INDIA do the following.

   time india

2. Search  for Keywords with Similar Meaning using   Google
    Instead of searching for only the given word, using ~ before the keyword you can instruct Google to             search for webpages with the exact given word or the words which has same meaning. In the following         example, giving ~tutorial also searches for keywords guide, manual, reference etc.

    Linux Installation ~tutorial

3. Match Any Single Word  in the Search Using *,While searching, if you are not sure about which               keyword to be placed in the phrase, you can match any single word using *.

    For example, if you want to search for examples of Jedit editor substitution, and you are not sure whether     to search for “Jedit editor find and replace examples”, or “Jedit editor search and replace examples”, then     use * , which will match either find, search or any other word, as shown below.

   Jedit editor * and replace examples

4. Use OR  in Google Search
    Using OR operator in between the words makes the following kind of search possible in Google.                 Following example will search for Cuda examples or Cuda programs.

    Cuda examples OR programs

Note: The keyword OR should be in uppercase


5. Identify Definition a Word. To view the definition of a word use the following method.

   define: Operating System

6. Mathematical  Calculations using Google,Normally for doing the metric conversions we will be using some    online conversion websites or conversion softwares.You can use the Google search box as your scientific      calculator as   
   
   sqrt(25)

7. Unit Conversion using Google, The following will show the equivalent pounds for one kg.

    kg  in pound

8. Money Conversion using Google, Following converts US Dollars in Rupees.
  
    USD  in INR

9. Translate Using Google, Use Google to translate whatever word you wish to see in other language.

     translate hello  into French

10. Identify Local Weather  for Any City  i n the World using Google, To see the current weather in Berlin          do the following.

     weather Berlin

Enjoy With Google Tricks

How to Lock Your Computer Using Mouse


Alt+Ctrl+Del or Windows+L to lock our PCs.Instead of trying those windows keyboard shortcut keys to lock Pc, lets now tryout something new.
Some might have already know this trick already…

1. Just Right click on the desktop, point to New and click Shortcut.

2. In the Create Shortcut dialog box, copy the following into the ‘Type the location’ of the
    item text box:

rundll32 user32.dll,LockWorkStation” remove quotes while typing.

3. Click Next.

4. In “Type a name for this shortcut”, type LOCK MY  PC and Click Finish

5. Now just double click on the icon, your desktop will be locked.

Though this is a age old trick.It makes some difference to newbies

Why Mark Zuckerberg’s Choose 4


Adding the Number 4 to the End of Facebook’s URL will Automatically Redirect you to Mark Zuckerberg’s Profile, Just in case you’re not familiar with the term “URL” – type in this web address: www.facebook.com/4.

We’re not sure why Zuckerberg chose the fourth ID number instead of number 1, but this is a quick and easy way to get to the original Facebook wall that is owned by its creator.

Adding the numbers 5 or 6 to the end of the URL will take you to the respective profiles of Chris Hughes and Dustin Moskovitz, Facebook co-founders and Mark’s former college roommates. Tacking a 7 onto the web address leads to the profile of Arie Hasit, another good friend of Zuckerberg from his days at Harvard.

Though this is a age old news.It makes some difference to newbies
Splitting the String TO Character Array using JAVA.........

Splitting the String TO Character Array using JAVA.........

Hi Friends this program will demonstrate the How to "Split String to Character Array".

Save the File SpiltStringTOCharArray.java

class SpiltStringTOCharArray
{
public static void main(String[] args)
{
String msg = "HELLO";
char a[]=msg.toCharArray();
                int i=0;
        
for( i=0;i<msg.length();i++)
              {
                   a[i]=msg.charAt(i);
           System.out.println("a["+i+"] value is : "+a[i] );
               }
}
}

OUTPUT :

a[0] value is : H
a[1] value is : E
a[2] value is : L
a[3] value is : L

a[4] value is : O

I hope this LOGIC will help full to all........
Convert Binary TO String Using JAVA.........

Convert Binary TO String Using JAVA.........

Hi Friends This Program Will Demonstrate the Logic of Binary TO String Conversion....

Save The File BinarytoStr.java

import java.math.BigInteger;
class BinarytoStr
{
public static void main(String[] args)
{
String z = "0100100001100101011011000110110001101111";
int len = z.length()/8;
String orgstring = "";
byte[] bval = new BigInteger(z, 2).toByteArray();
for(int t = 0;t<len;t++)
{
char c1 = (char)bval[t];
orgstring = orgstring.concat(String.valueOf(c1));
}
System.out.println("Original String : " + orgstring);
}
}

OUTPUT : 

Original String : Hello



I hope this logic will helpful to all...........
Convert String to Binary AND Binary To String Using Java......

Convert String to Binary AND Binary To String Using Java......

Hi Friends this program will demonstrate the logic for "How To Convert Sting to Binary AND Binary To Original String

Save The file Binary.java

class Binary
{
public static void main(String[] args)
{
String msg = "Hello";   //coverted String...

               //conversion of String To Binary.......

byte[] bytes = msg.getBytes();        //getting byte values
StringBuilder binary = new StringBuilder();
int msgg = 0;

for (byte b : bytes)
{
int val = b;
for (int i = 0; i < 8; i++)
{
binary.append((val & 128) == 0 ? 0 : 1);

   val <<= 1;

}

}

System.out.println("'" + msg + "' to binary: " + binary);
               
               //Conversion of Binary to Original String..........

                String origmsg = "";

int count = binary.length()/8;
     
char a[]=msg.toCharArray();
                int i=0;
     
for( i=0;i<count;i++)
               {
                    a[i]=msg.charAt(i);
           origmsg = origmsg.concat(String.valueOf(a[i]));
                }

System.out.println("original message : " + origmsg);
}
}


OUTPUT : 

'Hello' to binary: 0100100001100101011011000110110001101111
original message : Hello

I hope this logic will helpful to all...........
String To Binary Conversion using java.....

String To Binary Conversion using java.....

Hi Friends, Here the logic for "String to Binary(8 bit)" conversion

Save the file Binary.java

class Binary
{
public static void main(String[] args)
{
String msg = "Hello";           //coverted String...

byte[] bytes = msg.getBytes();             //getting byte values

StringBuilder binary = new StringBuilder();

int msgg = 0;

for (byte b : bytes)
{
int val = b;
for (int i = 0; i < 8; i++)
{
binary.append((val & 128) == 0 ? 0 : 1);

   val <<= 1;

}

}

System.out.println("'" + msg + "' to binary: " + binary);
       }
}

I hope it is usefulll....

File Upload Using Java(Servlets)........

Hi, Friends Here the sample code for upload a File or Image using java(Servlets). Apache Tomcat server is one of the most famous server for execute servlets. In this example I am using Apache Tomcat server.
The hierarchy structure to deploy the servlet file in tomcat web server


In our example "Web application name" is "upload"

 Note : Create one extra folder that is "UserUploadFiles" , Here we can save our uploaded files.

In order to compile and run this Java web application in any web server e.g. Tomcat, you need to include following dependency JAR in WEB-INF lib folder.

commons-fileupload-1.2.2.jar
(https://mega.co.nz/#!rc9GRDIA!Pfl4gQY_sUw26MLrfQPKhb4dkS7S--A0x36NiQ-cGJ4).

commons-io-2.4.jar (https://mega.co.nz/#!6E9hyRTB!RZQCJw4V3Ms6U7FTZWJkhIpJIMrlKEDe03mUX8Cn5K8).

You can download Apache Commons IO jar and Apache Commons FileUpload jar from URLs.

1. index.html which contains HTML content to setup a form, which allows user to select and upload file to     server.
2. UploadFile Servlet which handles file upload request and uses Apache FileUpload library to parse             multipart form data
3. web.xml to configure servlet in Java web application.


Save this file in "upload" folder......

Save File Name as index.html .

<html>
<head>
<title>File Upload Using Java(Servlet)</title>
</head>
<body>
</br>
</br>
<table border = "1">

<form action="./fileupload" method="post" enctype="multipart/form-data" name="form1" id="form1">

<tr>
<td><b>Upload File or Image</b></td>
<td><input name="file" type="file" id="file"></td>
</tr>
<tr>
<td><center><input type="submit" name="Submit" value="Submit"/></center></td>
<td><input type="reset" name="Reset" value="Reset"/></td>
</tr>

</form>

</table>

</body>
</html>




Save this file in "upload/WEB-INF" folder......

Save File Name as web.xml .
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

       <servlet>
<servlet-name>upload</servlet-name>
<servlet-class>UploadFile</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>upload</servlet-name>
<url-pattern>/fileupload</url-pattern>
</servlet-mapping>

</web-app>


Save this file in "upload/WEB-INF/classes" folder......

Save File Name as UploadFile.java .

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.disk.*;
public class UploadFile extends HttpServlet
{
  public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
  {
response.setContentType("text/html");
PrintWriter out= response.getWriter();
String itemName="";
boolean fileUpload=false;
try
{
 boolean isMultipart = ServletFileUpload.isMultipartContent(request);
 FileItemFactory factory = new DiskFileItemFactory();
 ServletFileUpload upload = new ServletFileUpload(factory);
 List items = null;
try
{
 items = upload.parseRequest(request);
}
catch (FileUploadException e)
{
 e.printStackTrace();
}
Iterator itr = items.iterator();
while (itr.hasNext())
{
 FileItem item = (FileItem) itr.next();
 String name = item.getFieldName();
 if(name.equals("file"))
 {
itemName = item.getName();
//In this example i am usnig ApacheTomcat Server..
//In ApacheTomcat Server our projets were placed in "webapps"..
//Here My Project name is "upload"..
//Create the folder with name "UserUploadFiles"..
//Here you can give the path i.e., where you want to save the File or Image..
String path="./webapps/upload/UserUploadFiles/";
File savedFile = new File(path+"/"+itemName);
out.println("savedFile:"+savedFile);
item.write(savedFile);
fileUpload = true; // If File or Image was sucessfully upload "fileUpload" is "true"
//Otherwise it will "false"
  }
}
if(fileUpload==true)
{
 out.println("File Uploaded Sucessfully Check in Your Path :)");
}
else
{
 out.println("File Uploaded UnSucessfully :(");
}
   }
   catch (Exception e)
   {
e.printStackTrace();
   }
  }
}



That's all...................


Download FileUploadServlet Example Project.....
(https://mega.co.nz/#!nN8wmKRD!cjpVYa4dnGRrEUQjRp8Gh4Dnzxp2EjskuT2tA3EKbG4)
A Basic Guide to the Internet

A Basic Guide to the Internet

The Internet is a computer network made up of thousands of networks worldwide. No one knows exactly how many computers are connected to the Internet. It is certain, however, that these number in the millions.
No one is in charge of the Internet. There are organizations which develop technical aspects of this network and set standards for creating applications on it, but no governing body is in control. The Internet backbone, through which Internet traffic flows, is owned by private companies.
All computers on the Internet communicate with one another using the Transmission Control Protocol/Internet Protocol suite, abbreviated to TCP/IP. Computers on the Internet use a client/server architecture. This means that the remote server machine provides files and services to the user's local client machine. Software can be installed on a client computer to take advantage of the latest access technology.
An Internet user has access to a wide variety of services: electronic mail, file transfer, vast information resources, interest group membership, interactive collaboration, multimedia displays, real-time broadcasting, shopping opportunities, breaking news, and much more.
The Internet consists primarily of a variety of access protocols. Many of these protocols feature programs that allow users to search for and retrieve material made available by the protocol.
--------------------------------------------------------------------------------
COMPONENTS OF THE INTERNET
--------------------------------------------------------------------------------
WORLD WIDE WEB
The World Wide Web (abbreviated as the Web or WWW) is a system of Internet servers that supports hypertext to access several Internet protocols on a single interface. Almost every protocol type available on the Internet is accessible on the Web. This includes e-mail, FTP, Telnet, and Usenet News. In addition to these, the World Wide Web has its own protocol: HyperText Transfer Protocol, or HTTP. These protocols will be explained later in this document.
The World Wide Web provides a single interface for accessing all these protocols. This creates a convenient and user-friendly environment. It is no longer necessary to be conversant in these protocols within separate, command-level environments. The Web gathers together these protocols into a single system. Because of this feature, and because of the Web's ability to work with multimedia and advanced programming languages, the Web is the fastest-growing component of the Internet.
The operation of the Web relies primarily on hypertext as its means of information retrieval. HyperText is a document containing words that connect to other documents. These words are called links and are selectable by the user. A single hypertext document can contain links to many documents. In the context of the Web, words or graphics may serve as links to other documents, images, video, and sound. Links may or may not follow a logical path, as each connection is programmed by the creator of the source document. Overall, the Web contains a complex virtual web of connections among a vast number of documents, graphics, videos, and sounds.
Producing hypertext for the Web is accomplished by creating documents with a language called HyperText Markup Language, or HTML. With HTML, tags are placed within the text to accomplish document formatting, visual features such as font size, italics and bold, and the creation of hypertext links. Graphics and multimedia may also be incorporated into an HTML document. HTML is an evolving language, with new tags being added as each upgrade of the language is developed and released. The World Wide Web Consortium (W3C), led by Web founder Tim Berners-Lee, coordinates the efforts of standardizing HTML. The W3C now calls the language XHTML and considers it to be an application of the XML language standard.
The World Wide Web consists of files, called pages or home pages, containing links to documents and resources throughout the Internet.
The Web provides a vast array of experiences including multimedia presentations, real-time collaboration, interactive pages, radio and television broadcasts, and the automatic "push" of information to a client computer. Programming languages such as Java, JavaScript, Visual Basic, Cold Fusion and XML are extending the capabilities of the Web. A growing amount of information on the Web is served dynamically from content stored in databases. The Web is therefore not a fixed entity, but one that is in a constant state of development and flux.
For more complete information about the World Wide Web, see Understanding The World Wide Web.
E-MAIL
Electronic mail, or e-mail, allows computer users locally and worldwide to exchange messages. Each user of e-mail has a mailbox address to which messages are sent. Messages sent through e-mail can arrive within a matter of seconds.
A powerful aspect of e-mail is the option to send electronic files to a person's e-mail address. Non-ASCII files, known as binary files, may be attached to e-mail messages. These files are referred to as MIME attachments.MIME stands for Multimedia Internet Mail Extension, and was developed to help e-mail software handle a variety of file types. For example, a document created in Microsoft Word can be attached to an e-mail message and retrieved by the recipient with the appropriate e-mail program. Many e-mail programs, including Eudora, Netscape Messenger, and Microsoft Outlook, offer the ability to read files written in HTML, which is itself a MIME type.
TELNET
Telnet is a program that allows you to log into computers on the Internet and use online databases, library catalogs, chat services, and more. There are no graphics in Telnet sessions, just text. To Telnet to a computer, you must know its address. This can consist of words (locis.loc.gov) or numbers (140.147.254.3). Some services require you to connect to a specific port on the remote computer. In this case, type the port number after the Internet address. Example: telnet nri.reston.va.us 185.
Telnet is available on the World Wide Web. Probably the most common Web-based resources available through Telnet have been library catalogs, though most catalogs have since migrated to the Web. A link to a Telnet resource may look like any other link, but it will launch a Telnet session to make the connection. A Telnet program must be installed on your local computer and configured to your Web browser in order to work.
With the increasing popularity of the Web, Telnet has become less frequently used as a means of access to information on the Internet.
FTP
FTP stands for File Transfer Protocol. This is both a program and the method used to transfer files between computers. Anonymous FTP is an option that allows users to transfer files from thousands of host computers on the Internet to their personal computer account. FTP sites contain books, articles, software, games, images, sounds, multimedia, course work, data sets, and more.
If your computer is directly connected to the Internet via an Ethernet cable, you can use one of several PC software programs, such as WS_FTP for Windows, to conduct a file transfer.
FTP transfers can be performed on the World Wide Web without the need for special software. In this case, the Web browser will suffice. Whenever you download software from a Web site to your local machine, you are using FTP. You can also retrieve FTP files via search engines such as FtpFind, located at /http://www.ftpfind.com/. This option is easiest because you do not need to know FTP program commands.
E-MAIL DISCUSSION GROUPS
One of the benefits of the Internet is the opportunity it offers to people worldwide to communicate via e-mail. The Internet is home to a large community of individuals who carry out active discussions organized around topic-oriented forums distributed by e-mail. These are administered by software programs. Probably the most common program is the listserv.
A great variety of topics are covered by listservs, many of them academic in nature. When you subscribe to a listserv, messages from other subscribers are automatically sent to your electronic mailbox. You subscribe to a listserv by sending an e-mail message to a computer program called a listserver. Listservers are located on computer networks throughout the world. This program handles subscription information and distributes messages to and from subscribers. You must have a e-mail account to participate in a listserv discussion group. Visit Tile.net at /http://tile.net/ to see an example of a site that offers a searchablecollection of e-mail discussion groups.
Majordomo and Listproc are two other programs that administer e-mail discussion groups. The commands for subscribing to and managing your list memberships are similar to those of listserv.
USENET NEWS
Usenet News is a global electronic bulletin board system in which millions of computer users exchange information on a vast range of topics. The major difference between Usenet News and e-mail discussion groups is the fact that Usenet messages are stored on central computers, and users must connect to these computers to read or download the messages posted to these groups. This is distinct from e-mail distribution, in which messages arrive in the electronic mailboxes of each list member.
Usenet itself is a set of machines that exchanges messages, or articles, from Usenet discussion forums, called newsgroups. Usenet administrators control their own sites, and decide which (if any) newsgroups to sponsor and which remote newsgroups to allow into the system.
There are thousands of Usenet newsgroups in existence. While many are academic in nature, numerous newsgroups are organized around recreational topics. Much serious computer-related work takes place in Usenet discussions. A small number of e-mail discussion groups also exist as Usenet newsgroups.
The Usenet newsfeed can be read by a variety of newsreader software programs. For example, the Netscape suite comes with a newsreader program called Messenger. Newsreaders are also available as standalone products.
FAQ, RFC, FYI
FAQ stands for Frequently Asked Questions. These are periodic postings to Usenet newsgroups that contain a wealth of information related to the topic of the newsgroup. Many FAQs are quite extensive. FAQs are available by subscribing to individual Usenet newsgroups. A Web-based collection of FAQ resources has been collected by The Internet FAQ Consortium and is available at /http://www.faqs.org/.
RFC stands for Request for Comments. These are documents created by and distributed to the Internet community to help define the nuts and bolts of the Internet. They contain both technical specifications and general information.
FYI stands for For Your Information. These notes are a subset of RFCs and contain information of interest to new Internet users.
Links to indexes of all three of these information resources are available on the University Libraries Web site at /http://library.albany.edu/reference/faqs.html.
CHAT & INSTANT MESSAGING
Chat programs allow users on the Internet to communicate with each other by typing in real time. They are sometimes included as a feature of a Web site, where users can log into the "chat room" to exchange comments and information about the topics addressed on the site. Chat may take other, more wide-ranging forms. For example, America Online is well known for sponsoring a number of topical chat rooms.
Internet Relay Chat (IRC) is a service through which participants can communicate to each other on hundreds of channels. These channels are usually based on specific topics. While many topics are frivolous, substantive conversations are also taking place. To access IRC, you must use an IRC software program.
A variation of chat is the phenomenon of instant messenging. With instant messenging, a user on the Web can contact another user currently logged in and type a conversation. Most famous is America Online's Instant Messenger. ICQ, MSN and Yahoo are other commonly-used chat programs.
Other types of real-time communication are addressed in the tutorial Understanding the World Wide Web.
MUD/MUSH/MOO/MUCK/DUM/MUSE
MUD stands for Multi User Dimension. MUDs, and their variations listed above, are multi-user virtual reality games based on simulated worlds. Traditionally text based, graphical MUDs now exist. There are MUDs of all kinds on the Internet, and many can be joined free of charge.