skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

  • Home
 
  • RSS
  • Twitter
Saturday, November 3, 2012

Parse XML file using DOM

Posted by Raju Gupta at 12:00 AM – 0 comments
 

This code snippet explains about the parsing of the xml file using the DOM parser.


import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;


public class XMLParser {

    /**
     * @param args
     * @throws IOException 
     * @throws SAXException 
     */
    
    public void GetXMLValue(String FileName){
    
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db         = dbf.newDocumentBuilder();
            File file                  = new File(FileName);
            
            if(file.exists()){
                Document doc = null;
                try {
                    doc = db.parse(file);
                }
                catch (SAXException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                Element docelement1     = doc.getDocumentElement();
                
                System.out.println("Root element of the document: "
                        + docelement1.getNodeName());                
                //for commercial credit
                NodeList valueList1 = docelement1.getElementsByTagName("CommercialCredit");
                
                if (valueList1 != null && valueList1.getLength() > 0) {
                 
                    for (int i = 0; i < valueList1.getLength(); i++) {
                        
                        Node node = valueList1.item(i);
                        
                        if (node.getNodeType() == Node.ELEMENT_NODE) {
                            
                            Element e = (Element) node;
                            NodeList nodeList = e.getElementsByTagName("DistSourceId");
                            System.out.println("DistSourceId: "
                                    + nodeList.item(0).getChildNodes().item(0)
                                            .getNodeValue());

                            nodeList = e.getElementsByTagName("MMSReferenceStartTime");
                            System.out.println("MMSReferenceStartTime: "
                                    + nodeList.item(0).getChildNodes().item(0)
                                            .getNodeValue());

                            nodeList = e.getElementsByTagName("MMSReferenceEndTime");
                            System.out.println("MMSReferenceEndTime: "
                                    + nodeList.item(0).getChildNodes().item(0)
                                            .getNodeValue());  
                        }                        
                     // for Credit result ---- added only 3 fields to test.....                        
                        
                        NodeList valueList2 = docelement1.getElementsByTagName("CreditResult");
                        if (valueList2 != null && valueList2.getLength() > 0) {
                            
                            for (int j = 0; j < valueList2.getLength(); j++) {
                                
                                Element e2 = (Element) node;
                                NodeList nodeList2 = e2.getElementsByTagName("MediaAssetId");
                                System.out.println("MediaAssetId: "
                                        + nodeList2.item(0).getChildNodes().item(0)
                                                .getNodeValue());
                                
                                nodeList2 = e2.getElementsByTagName("DetectedTime");
                                System.out.println("DetectedTime: "
                                        + nodeList2.item(0).getChildNodes().item(0)
                                                .getNodeValue());
                                
                                nodeList2 = e2.getElementsByTagName("DetectedSourceId");
                                System.out.println("DetectedSourceId: "
                                        + nodeList2.item(0).getChildNodes().item(0)
                                                .getNodeValue());  
                            }
                        }//if ends here
                    }  
                }
                else{
                    System.exit(1);
                }                    
            }
        }
        catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }         
    }    
    
    public static void main (String[] args) throws SAXException, IOException {
        // TODO Auto-generated method stub
        String str = "C:\Test\Mytestfile.xml";
        new XMLParser().GetXMLValue(str);

    }

}

[ Read More ]
Read more...
Friday, November 2, 2012

Listing Files and Directory Using Java

Posted by Raju Gupta at 9:30 PM – 0 comments
 

Lists Files and directory present in the system   

File dir = new File("directoryName"); 
 String[] children = dir.list();
  if (children == null) 
{      
// Either dir does not exist or is not a directory 
 }
 else 
{   
   for (int i=0; i < children.length; i++) 
{
          // Get filename of file or directory       
   String filename = children[i];     
 }
  }
   // It is also possible to filter the list of returned files.
  // This example does not return any files that start with `.'.  
FilenameFilter filter = new FilenameFilter() 
{      
public boolean accept(File dir, String name)
 {
          return !name.startsWith(".");    
  }
  };
  children = dir.list(filter);
   // The list of files can also be retrieved as File 
File[] files = dir.listFiles();   
// This filter only returns directories  
FileFilter fileFilter = new FileFilter()
 {

      public boolean accept(File file)
 {
          return file.isDirectory();   
   }
  };  
files = dir.listFiles(fileFilter); 


[ Read More ]
Read more...

To Capture screen shots using Java

Posted by Raju Gupta at 11:30 AM – 0 comments
 

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
public void captureScreen(String fileName) throws Exception 
{
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();   
Rectangle screenRectangle = new Rectangle(screenSize);  
 Robot robot = new Robot();  
 BufferedImage image = robot.createScreenCapture(screenRectangle);  
 ImageIO.write(image, "png", new File(fileName)); 
}


[ Read More ]
Read more...

Extract a zip file in Java

Posted by Raju Gupta at 3:48 AM – 0 comments
 

The sole purpose of this program is how to extarct the content of a zip file in java.We start by opening an input stream to the compressed file and an output stream to the file where we want the content to be extracted.
After that we get the next entry of the zip file (and the only entry in this case) - test so it's not null, and then start reading the contents from the input stream and writing each chunk read to the output stream.
As usual we should clean up properly afterwards so we close the input and output streams.


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class ExtractingZipFile{

    /**
     * Extracts a zip file
     */
    public void extractZipFile() {
        
        try {
            String zipFileName = "file.zip";
            String extractedFileName = "extractedfile.txt";
            
            //Create input and output streams
            ZipInputStream inStream = new ZipInputStream(new FileInputStream(zipFileName));
            OutputStream outStream = new FileOutputStream(extractedFileName);
            
            ZipEntry entry;
            byte[] buffer = new byte[1024];
            int nrBytesRead;
            
            //Get next zip entry and start reading data
            if ((entry = inStream.getNextEntry()) != null) {
                while ((nrBytesRead = inStream.read(buffer)) > 0) {
                    outStream.write(buffer, 0, nrBytesRead);
                }
            }
                    
            //Finish off by closing the streams
            outStream.close();
            inStream.close();
            
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new ExtractingZipFile().extractZipFile();
    }
    
}


[ Read More ]
Read more...

Albers Square using JAVA

Posted by Raju Gupta at 12:00 AM – 0 comments
 

Albers Square using JAVA

public class AlbersSquares {

    public static void main(String[] args) {

        StdDraw.setCanvasSize(800, 800);

        // first color
        int r1 = Integer.parseInt(args[0]);
        int g1 = Integer.parseInt(args[1]);
        int b1 = Integer.parseInt(args[2]);
        Color c1 = new Color(r1, g1, b1);

        // second color
        int r2 = Integer.parseInt(args[3]);
        int g2 = Integer.parseInt(args[4]);
        int b2 = Integer.parseInt(args[5]);
        Color c2 = new Color(r2, g2, b2);

        // first Albers square
        StdDraw.setPenColor(c1);
        StdDraw.filledSquare(.25, .5, .2);
        StdDraw.setPenColor(c2);
        StdDraw.filledSquare(.25, .5, .1);

        // second Albers square
        StdDraw.setPenColor(c2);
        StdDraw.filledSquare(.75, .5, .2);
        StdDraw.setPenColor(c1);
        StdDraw.filledSquare(.75, .5, .1);
    } 
} 


[ Read More ]
Read more...
Thursday, November 1, 2012

Doubling Stack of Strings using Java

Posted by Raju Gupta at 3:30 PM – 0 comments
 

Doubling Stack of Strings using Java  

import java.util.Iterator;
import java.util.NoSuchElementException;

public class DoublingStackOfStrings implements Iterable<String> {
    private String[] a;
    private int N;

    public DoublingStackOfStrings() {
        a = new String[2];
        N = 0;
    }

    // is the stack empty?
    public boolean isEmpty() {  return (N == 0);  }

    // resize the underlying array holding the elements
    private void resize(int capacity) {
        String[] temp = new String[capacity];
        for (int i = 0; i < N; i++) {
            temp[i] = a[i];
        }
        a = temp;
    }

    // push a new item onto the stack
    public void push(String item) {
        if (N == a.length) resize(2*a.length);
        a[N++] = item;
    }

    // delete and return the item most recently added
    public String pop() {
        if (isEmpty()) { throw new RuntimeException("Stack underflow error"); }
        String item = a[--N];
        a[N] = null;  // to avoid loitering
        if (N > 0 && N == a.length/4) resize(a.length/2);
        return item;
    }

    public Iterator<String> iterator()  { return new ReverseArrayIterator();  }

    // an iterator, doesn't implement remove() since it's optional
    private class ReverseArrayIterator implements Iterator<String> {
        private int i = N;
        public boolean hasNext()  { return i > 0;                               }
        public void remove()      { throw new UnsupportedOperationException();  }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            return a[--i];
        }
    }

    // test client
    public static void main(String[] args) {
        DoublingStackOfStrings s = new DoublingStackOfStrings();
        while (!StdIn.isEmpty()) {
            String item = StdIn.readString();
            if (!item.equals("-")) s.push(item);
            else if (s.isEmpty())  StdOut.println("BAD INPUT");
            else                   StdOut.print(s.pop());
        }
    }

}

[ Read More ]
Read more...

Excel Comparator xls or xlsx in java

Posted by Raju Gupta at 10:30 AM – 0 comments
 

we can compare any two excels of extension either xls or xlsx   

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class Excelcomparison {
 ArrayList<String> listOfTerms =null;
 ArrayList<String> al =new ArrayList<String>();
 ArrayList<String> finallist = new ArrayList<String>();
 public  Workbook checkFileFormat(String fileName){
  Workbook hwb=null;
  
  FileInputStream checkFis=null;
  try{
    checkFis=new FileInputStream(fileName);
    //Instantiate the Workbook using HSSFWorkbook
    hwb=(Workbook)new HSSFWorkbook(checkFis);
    Sheet sheet=hwb.getSheetAt(0);
    Iterator<Row> rows=sheet.rowIterator();
   
    Iterator<Cell> cells=null;
    Row row=null;
    Cell cell=null;
    int check=0;
    //Read the file as HSSFWorkbook
    while(rows.hasNext()){
    check++;
    row=(HSSFRow)rows.next();
    cells=row.cellIterator();
    while(cells.hasNext()){
     cell=(HSSFCell)cells.next();
    }
    if(check==2)
     break;
   }
   //Return HSSFWorkbook type object if there is no exception in reading the file using HSSFWorkbook
   return hwb;
  }catch(ClassCastException ce){  //Instantiate the Workbook using XSSFWorkbook in case of class cast exception
   Workbook xwb=null;
   try{
   xwb=new XSSFWorkbook(checkFis);  
   checkFis.close();
   }catch(IOException e){    
   e.printStackTrace();
     }
  return xwb; }
  catch(Exception e){ //Instantiate the Workbook using XSSFWorkbook in case of Exception while reading file through HSSFWorkbook
  Workbook xwb=null;
  try{
   if(checkFis!=null)
  checkFis.close();
  checkFis=null;
  checkFis=new FileInputStream(fileName);
  xwb=new XSSFWorkbook(checkFis); 
  checkFis.close();
  }catch(Exception ie){
   
 return null;
  }
  
 return xwb;
 }
 }
 public void readExcel()
 {
  try
  {
   Workbook workbook = checkFileFormat("EXCEL1.xlsx");
  listOfTerms =new ArrayList<String>();
  Sheet sheet = workbook.getSheetAt(0);
  int rows  = sheet.getPhysicalNumberOfRows();
  System.out.println("here "+rows+"   "+sheet.getSheetName());
  for (int r = 0; r < rows; r++)
  {
       Row row   = sheet.getRow(r);
       Cell cell =row.getCell((short)0);
       String cellValue = cell.getStringCellValue().trim();
       listOfTerms.add(cellValue);
    }
      System.out.println(listOfTerms);
      Workbook workbook1 = checkFileFormat("EXCEL2.xls");
      Sheet sheet1 = workbook1.getSheetAt(0);
      int rows1  = sheet1.getPhysicalNumberOfRows();
      System.out.println("here "+rows1+"   "+sheet.getSheetName());
      for (int k = 0; k < rows1; k++)
      {
         Row row1   = sheet.getRow(k);
        Cell cell =row1.getCell((short)0);
         String cellValue2 = cell.getStringCellValue();
         al.add(cellValue2);
       
      }
        System.out.println(al);
        for(int i=0; i<al.size(); i++)
        {
        
          if(!listOfTerms.contains(al.get(i))) 
           {
             finallist.add(al.get(i));
           }
        }
        for(int i=0; i<listOfTerms.size(); i++)
        {
          if(!al.contains(listOfTerms.get(i))) 
          {
            finallist.add(listOfTerms.get(i));
          }
        }
        System.out.println("Elements which are different: " +finallist);
        System.out.println(""); 
 createSheet();
  }catch(Exception e)
  {
   e.getStackTrace();
   System.out.println(e.getMessage());
  }
 }
 private void createSheet() {
  XSSFWorkbook bookout = new XSSFWorkbook();
  try
  {
   int j=0;
   XSSFSheet sheet1= bookout.createSheet();
   bookout.setSheetName(0,"Document Handles");
    for(int m=0;m<finallist.size();m++)
    {
     XSSFRow row=sheet1.createRow(j++);
     row.createCell((short) 0).setCellValue(finallist.get(m));
     
    } 
    FileOutputStream fout = new FileOutputStream("OutputExcel.xlsx");
    bookout.write(fout);
    fout.close();
  System.out.println("file completed"); 
  }
  catch(Exception e)
  {
   System.out.println(e.getMessage());
  }
 }
  public static void main(String args[]){
  Excelcomparison e = new Excelcomparison();
  e.readExcel();
 }
}

[ Read More ]
Read more...

Code to Remove Certain Characters from a Java Input

Posted by Raju Gupta at 3:35 AM – 0 comments
 

Sometimes we can't rename a file automatically when the Filename has "/" inside them because of Windows limitations. This code might prove handy in these situations.

//Code to Remove Certain Characters from a Java Input//

try {
    String Y = X;
    String regx = "/";
    char[] ca = regx.toCharArray();
    for (char c : ca) {
     Y = Y.replace("" + c, "");
}

[ Read More ]
Read more...

Code to Populate Dropdown from a DB

Posted by Raju Gupta at 12:00 AM – 0 comments
 

Using this Java snippet the users can Populate Dropdown from a DB   

//Code to Populate Dropdown from a DB//
//In JSP//
<div id="bodydiv" align="center" >
    <select name=" Name" onchange="this.form.submit();">
     <option name="Router Name" value="0">--------select--------</option>
     <%
     GetXRouter dao = new GetXRouter();
     ArrayList ReList = dao.retreiveRname();
     for (int i = 0; i < ReList.size(); i++) {
    %>
     <option name="RName" value="<%=ReList.get(i)%>"><%=ReList.get(i)%></option>
     <%
     }
    %>
    </select>

//IN Java Class File//
public class GetList {
 static Connection conn = null;
 static Statement st = null;
 static ResultSet rs = null;
 static DBConnection db;

 
 @SuppressWarnings({ "rawtypes", "unchecked" })
 public ArrayList retreiveIname(String Rname) throws SQLException {
  Connection conn;
  DBConnection db = new DBConnection();
  conn = db.getConnection();
  Statement st;
  st = conn.createStatement();
  ResultSet rs = st.executeQuery("select tt.Y_nm from Z.Z_X_Y_cfg tt where tt.active = 'A' and tt.X_nm = '"+Rname+"' ");
  ArrayList IList = new ArrayList();
  while (rs.next()) {
   IList.add(rs.getString(1));
  }
  for (int i = 0; i < IList.size(); i++) {
   System.out.println(IList.get(i));
  }
  return IList;

 }

}

[ Read More ]
Read more...
Newer Posts Older Posts
Subscribe to: Posts ( Atom )

List of Java Programs

  • Java Program to check Greater between the Two Number
  • Java Program to find that given number is Palindrome or not
  • Java Program to Demonstrate the Use of Pre and Post Operator
  • Java Program to Reverse the Given Number
  • Java Program to Print Number in the Given Data Type
  • Program to Demonstrate Skipping using Continue
  • Program to find whether entered character is a vowel or Consonant
  • Java Program to Calculate the Sum of Digits of Given Number
  • How to swap two numbers using only two variables
  • Checking the Given Number is Armstrong or Not
  • Average an Array of Values
  • Display ASCII Code Instead of Character
  • Comparison of Two Variable using If
  • Printing Table In java using While Loop
  • Generate Random Number Using Math.Random Function
  • To Find roots of Quadratic Equation
  • Performing Arithmetic Opration on Two Variable
  • Concatenation of Two String in Java
  • Command Line Argument in JAVA
  • Java Hello World Program
  • Calculate Circle Perimeter | Java Program
  • Calculate the Area of Circle | Java Program
  • To Find Whether Given Year is a Leap Year or not
  • Popular
  • Recent
  • Archives

Total Pageviews

Sparkline

Followers

Popular Posts of This Week

  • Java Class to Calculate the Volume of Box
    Here is a Java Class to Calculate the Volume of Box. class Box { double width; double height; double depth; // This is the con...
  • UDP Client Server Communication using Java
    UDP uses a simple transmission model without implicit handshaking dialogues for providing reliability, ordering, or data integrity. Here ...
  • Connecting Sybase using JDBC
    This is a java code snippet which can be used to connect Sybase database using JDBC driver (SybDriver). Jconnect is the name of the packag...
  • Convert TEXT to PDF file using Java
    To create a PDF file from the TEXT file using Java. The Text file withe path is given as input and the created PDF will be saved in the same...
  • Caching implementation using Static variable
    In we application perfromance can be improved by caching some Datatable in Memory. Using the given code data can be cached on application s...
  • Run Excel Macro from Java
    This is a java code snippet which will run VB script (.vbs file) which in turn will run an excel macro. 1. The excel macro called "...
  • Convert an integer into binary, hexadecimal, and octal.
    Here is a Java Program to Convert an integer into binary, hexadecimal, and octal. class StringConversions { public static void main(Str...
  • Java Program to tells whether the Temperature is Hot or not
    Here is a Java Program to tells whether the Temperature is Hot or not import java.util.*; class weather{ public static void main (String...
  • Java Program to Calculate and output the amount of tax to pay in dollars and cents
    Write a program that defines a floating-point variable initialized with a dollar value for your income and a second floating-point variable...
  • writes file content to a Database CLOB
    This utility tool writes file content to a Database CLOB . The tool reads the list of files , creates CLOB of the files and updates the ...
Powered by Blogger.

Archives

  • ►  2014 ( 4 )
    • ►  August ( 4 )
  • ►  2013 ( 6 )
    • ►  August ( 1 )
    • ►  April ( 5 )
  • ▼  2012 ( 673 )
    • ▼  November ( 9 )
      • Parse XML file using DOM
      • Listing Files and Directory Using Java
      • To Capture screen shots using Java
      • Extract a zip file in Java
      • Albers Square using JAVA
      • Doubling Stack of Strings using Java
      • Excel Comparator xls or xlsx in java
      • Code to Remove Certain Characters from a Java Input
      • Code to Populate Dropdown from a DB
    • ►  October ( 223 )
    • ►  September ( 272 )
    • ►  August ( 2 )
    • ►  June ( 1 )
    • ►  February ( 67 )
    • ►  January ( 99 )
 

Our Blogs

  • Linux Tutorial
  • C Programming Tutorial

Labels

  • Agile Methodology ( 1 )
  • Algorithm ( 3 )
  • AntiSamy ( 1 )
  • Arithmetic Operation ( 1 )
  • Array Example ( 9 )
  • ArrayList Examples ( 11 )
  • Average an Array of Values ( 1 )
  • Barcode Example ( 1 )
  • Basic Java Programs ( 34 )
  • Bing API Example ( 2 )
  • BitSet Example ( 1 )
  • Boolean Example ( 1 )
  • Bouncy Castle API ( 1 )
  • Break Statement ( 2 )
  • BufferedReader Example ( 2 )
  • Calendar Example ( 1 )
  • Chart Generation Example ( 1 )
  • Command Line Argument ( 1 )
  • Comparator Example ( 1 )
  • Concatenation of String ( 1 )
  • Continue Statement ( 1 )
  • Control Structure ( 1 )
  • Copy File Example ( 1 )
  • CRC Example ( 1 )
  • CSV Example ( 6 )
  • Data Structure ( 5 )
  • Date Example ( 2 )
  • Directory Example ( 1 )
  • Do - While Loop Example ( 1 )
  • Domino Database ( 1 )
  • Email Example ( 8 )
  • Encryption Example ( 3 )
  • Excel Example ( 15 )
  • Factorial Example ( 1 )
  • File Upload Example ( 1 )
  • Find Roots of Quadratic Equation ( 1 )
  • FTP Example ( 2 )
  • Graph Examples ( 1 )
  • Greater between Two Numbers ( 1 )
  • GSON Library ( 1 )
  • HashMap Example ( 1 )
  • HashSet Example ( 1 )
  • Hello World Program ( 1 )
  • If Condition ( 2 )
  • Inner Class Example ( 1 )
  • iText Example ( 3 )
  • JAR File ( 1 )
  • JAVA Applet ( 1 )
  • Java Applications ( 1 )
  • Java AWT Example ( 9 )
  • Java Certification ( 1 )
  • Java Class Examples ( 15 )
  • Java Collection Example ( 1 )
  • Java Command Example ( 4 )
  • Java Constructor Examples ( 1 )
  • Java Currency Example ( 1 )
  • Java Database Example ( 3 )
  • Java Date and Time Example ( 3 )
  • Java DateFormat Example ( 3 )
  • Java Examples ( 2 )
  • Java Exception Example ( 5 )
  • Java File Example ( 22 )
  • Java GUI Example ( 1 )
  • Java Image Examle ( 3 )
  • Java Inheritance Example ( 3 )
  • Java Input Output Example ( 1 )
  • Java IO Example ( 3 )
  • Java Jar Example ( 1 )
  • Java JSON Example ( 3 )
  • Java Mail Examples ( 4 )
  • Java Map Example ( 5 )
  • Java MapReduce Example ( 2 )
  • Java MultiThreading Example ( 7 )
  • Java Network Example ( 9 )
  • Java Package ( 1 )
  • Java Programs ( 1 )
  • Java RMI ( 1 )
  • Java Robot Class Examples ( 2 )
  • Java Runtime Example ( 1 )
  • Java Swing Example ( 9 )
  • Java Util Example ( 1 )
  • Java Vector Example ( 4 )
  • Java Voice Example ( 1 )
  • Java Webservice Example ( 1 )
  • Java XML Example ( 3 )
  • Java Zip Class Examples ( 2 )
  • JDBC ( 9 )
  • JDK Version Comparison ( 1 )
  • JFrame Example ( 3 )
  • JOptionPane Dialog Example ( 1 )
  • JPanel Example ( 1 )
  • JSP Example ( 2 )
  • JSTL Example ( 1 )
  • jUnit Example ( 2 )
  • LinkedList Example ( 2 )
  • List Example ( 1 )
  • Long Variable ( 1 )
  • Lottery Nubmer ( 1 )
  • MD5 Hashing Example ( 3 )
  • Memory Management Example ( 1 )
  • Method Override ( 1 )
  • MIDI Sound ( 8 )
  • Module Operator Example ( 2 )
  • Multiplication Table ( 1 )
  • Observer Interface Example ( 1 )
  • Operator Example ( 5 )
  • Pagination ( 1 )
  • Palindrome Number ( 1 )
  • Pass By Reference Example ( 1 )
  • Pass By Value Example ( 1 )
  • PDF File Example ( 3 )
  • PDF Generation Example ( 4 )
  • Pre and Post Operator ( 2 )
  • Prime Number ( 3 )
  • Progress Bar Example ( 1 )
  • Property List Example ( 2 )
  • Random Function ( 7 )
  • Recursion Example ( 2 )
  • Regex Example ( 2 )
  • Remote Host Example ( 2 )
  • Robot Class ( 4 )
  • Searching Example ( 3 )
  • Slideshow ( 1 )
  • Sorting Example ( 7 )
  • SpringLayout Example ( 1 )
  • Stack Example ( 4 )
  • Static Variable ( 1 )
  • StreamTokenizer Example ( 2 )
  • String Example ( 19 )
  • Struts2 Example ( 1 )
  • Sum of Digits ( 1 )
  • Swap Two Numbers ( 1 )
  • Switch Case ( 3 )
  • Tapestry Components ( 1 )
  • Thumbnail Example ( 2 )
  • TimerTask Example ( 2 )
  • To Calculate Volume ( 1 )
  • To Check Armstrong Number ( 1 )
  • Tree Example ( 1 )
  • TreeMap Example ( 1 )
  • TreeSet Example ( 1 )
  • Two Dimensional Array Example ( 1 )
  • UUID ( 1 )
  • Validation Example ( 2 )
  • Variable Casting ( 1 )
  • While Loop ( 1 )
  • XML Parsing ( 7 )
  • XSS Attacks ( 1 )
  • Zip File ( 15 )

Popular Posts

  • Java Class to Calculate the Volume of Box
    Here is a Java Class to Calculate the Volume of Box. class Box { double width; double height; double depth; // This is the con...
  • UDP Client Server Communication using Java
    UDP uses a simple transmission model without implicit handshaking dialogues for providing reliability, ordering, or data integrity. Here ...
  • Singly linked list with header - Data Structure
    class OrderedList { private int value; private OrderedList next; // Note: No setValue() method or setNext() methods are provide...
  • Run Excel Macro from Java
    This is a java code snippet which will run VB script (.vbs file) which in turn will run an excel macro. 1. The excel macro called "...
  • SPLIT HUGE FILES INTO SMALL TEXT FILES
    This code snippet is used for automatic splitting of files conatining large content into smaller text files with specific number of recor...
  • Java Program to Generate the Lottery Number between 1 to 49
     A lottery requires that you select six different numbers from the integers 1 to 49. Write a program to do this for you and generate five s...
  • Java class that defines an integer stack that can hold 10 values
    Here is a Java class that defines an integer stack that can hold 10 values. class Stack { int stck[] = new int[10]; int tos; // ...
  • Remove Duplicate Rows in Excel using Java
    This is a reusable code written in Java with a simple Standalone program. User can just run this program with the two command line arguments...
  • Connecting Sybase using JDBC
    This is a java code snippet which can be used to connect Sybase database using JDBC driver (SybDriver). Jconnect is the name of the packag...
  • Program to Create a Rectangle objects defined by Two Points
    Define a class for rectangle objects defined by two points, the top-left and bottom-right corners of the rectangle. Include a constructor t...
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger