Skip to main content


Showing posts from May, 2009

String hadnling

String is the sequence of character represented by the object of String class in java. Two other classes’ string buffer and string builder can be used for same thing. String object provides some predefined method those are used to manipulate the string. String object is said to be the immutable this means that you can not manipulate the string object. But you can work with that object. When you manipulate the string object then new string object is created and it consists of manipulated contents. But it is hard to observe by programmer without experience. Here to solve this problem you can use the String buffer class to create the string object in which you can manipulate the string contents with the same object. That is the object of string class the mutable. String buffer is the thread safe. Another class to create the mutable string objects is string builder class. But it is no thread safe. Creating String There are many ways to create the string object 1 You can dec

Java : Using Runtime to Play song in media player

import * ; class FileDemo1 { public static void main( String ar []) throws Exception { //Runtime.getRuntime().exec("D:\\Program Files\\Windows Media Player\\wmplayer.exe"); Runtime . getRuntime().exec( "D:\\Program Files\\Windows Media Player\\wmplayer.exe \"F:\\V\\SONGS\\Dostana\\desi girl.mp3\"" ) ; } }

Java : Properties Class

import java.util. * ; import * ; class PropertiesDemo { public static void main ( String ar []) { Properties prop = new Properties () ; try { prop. setProperty ( "" , "ABC xyz" ) ; prop. setProperty ( "" , "3453545" ) ; FileOutputStream fout = new FileOutputStream ( "" ) ; prop. store ( fout, "My Properties" ) ; } catch ( Exception e ){} } } ****************************************************************************** import java.util. * ; import * ; class PropertiesDemo2 { public static void main ( String ar []) { Properties prop = new Properties () ; try

SSL and TLS security

  SSL and TLS security SSL statnds for Secure Socket layer and TLS statds for Transport layersecurity. Both are succeser of cryptography protocols which provides secure communication on the network. Both securitiesa are used to secure various services like email, internet faxing, ftp file transfer etc. SSL provides enpoint authentication and communication privacy over the internet. In typical use only servr is authenticated but in mutual authentication both are authenticated to each other using public key encryption(PKI). The protocol allows client/server applications to coomunicate through secure channel in which data or information is pervanted to eavesdroping, tampering and message forgery.

Working with Date and Time

  import  java.util. * ; import  java.text. * ; import  java.text. DateFormat ; import  java.text. ParseException ; import  java.text. SimpleDateFormat ; import  java.util. Calendar ; import  java.util. Date ; /**  *This class has all method to be used by Timesheet throught the date and time related operations  * @author Hemraj  */ public   class  DateTime  {      /**      * Change the date represented by Date object into the date format that is accepted by MS SQL Server       * @param d      * @return      */      public   String   dateTime ( Date  d )   {          Calendar  c  =   new  java.util. GregorianCalendar () ;         c. setTime ( d ) ;          int  yy  =  c. get ( Calendar .YEAR ) ;          int  mm  =  c. get ( Calendar .MONTH )   +   1 ;          int  dd  =  c. get ( Calendar .DATE ) ;          int  m  =  c. get ( Calendar .MINUTE ) ;          int  s  =  c. get ( Calendar .SECOND ) ;          int  hour  =  c. get ( Calendar .HOUR_OF_DAY ) ;