JAVA

JAVA is a programming language originally developed by James Gosling at Sun Microsystems and was released in the year 1995 as a open source language that any body can download by acceptings its terms and conditions. As java was launched it gain the popularity among programmers and web developers and hence it is still very much popular and alive among the developer. The popularity of java can be noticed by the fact that java is used on a large scale not only by developres for making sofwares and applications but it is also widely used in the mobile as an operating system. Today's all most of the applications like softwares, games etc in mobile are made in java platform.

Features of Java Language.

1) Java is platform independent
    It means code develop on one machine can be easily run on other machine without any
    difficulty.

2) Java is Free to download for any one.

3) Java Supports console as well as Graphical Interface

4) It is a Interpreted language.

5) Java has both compiler as well as interpreter.

    Javac- This is Compiler of Java.

   Java- This is Interpreter of java which interprets the class file produced by the compiler and  
   also executes.

6) The Code develop in java executes in High Performance.

Below is a Simple Java Program

Topic:  java prg to create a class called FileWatcher that can be given several filenames
that may or may not exist. the class should start a thread for each file name
Each thread will periodically check for the existance of it's file.
If the file exist,the thread will write a message to the console & then end


import java.io.*;
class SlipFileWatch
{
 public static void main(String args[]) throws IOException
  {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("\n Enter Several N  files");
        try
        {
          int n =Integer.parseInt(br.readLine());
          System.out.println("\n Enter File name");
          for(int i=1;i<=n;i++)
                  new FileWatcher(br.readLine());
        } 
        catch(Exception e)
        { System.out.println("Invalid Input");}
    }
}  
   
class FileWatcher implements Runnable
{
    Thread T;
    String fname;
    FileWatcher(String fn)
    {
        fname=fn;
        T=new Thread(this,fname);
        System.out.println("\n\nNew = "+T);
        T.start();
    }
   
    public void run()
    {
        File f = new File(fname);
        if(f.exists())
          System.out.println(" "+fname+"  File Exist ");
        else
          System.out.println(" "+fname+"  File Not Exist");
         try
          {
              Thread.sleep(1000);
          }
          catch(InterruptedException it){}
    }
}

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...