Thursday, July 28, 2011
Tuesday, July 26, 2011
MARKET SAYS Samsung is leading to Apple and Nokia in smartphone sales for first time
SAMSUNG is growing up in smart phone sales.
it is estimated that company has 18 mn to 21 mn smartphones in April-June period.
Company's Galaxy Smart phone model with android OS (Operaing System) is best gadgest said by a research company.
market says that samsung may have surpassedNokia and Apple in smartphone sales
NICE JAVA CODE TO SHOW ANALOG CLOCK ON YOUR SCREEN
/*
Author : RK
Aim : ANALOG CLOCK INSIDE A JFrame
*/
import java.awt.Toolkit;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Calendar;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.UIManager;
class AnalogClock extends JComponent implements Runnable
{
private static Stroke SEC_STROKE = new BasicStroke();
private static Stroke MIN_STROKE =new BasicStroke(4F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
private static Stroke HOUR_STROKE = MIN_STROKE;
private double sa = Math.PI / 2;
private double sda = Math.PI / 30;
private double mda = sda / 60;
private double hda = mda / 12;
int sx,sy,cenx,ceny;
String mday="";
int wday=0;
String swday="";
int month=0;
String year="";
String smonth="";
public AnalogClock()
{
(new Thread(this)).start();
Toolkit toolkit=Toolkit.getDefaultToolkit();
Dimension dim=toolkit.getScreenSize();
JFrame f = new JFrame("Analog Clock");
f.setUndecorated(true);
f.setResizable(false);
f.getContentPane().add(this);
Color c=new Color(135,200,41);
f.getContentPane().setBackground(Color.BLACK);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}});
f.setVisible(true);
f.setBounds(dim.width-120, 4, 118, 200);
}
public void run()
{
try {
for(;;)
{
Thread.sleep(500);
repaint();
}
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
@SuppressWarnings("empty-statement")
public void paint(Graphics graphics)
{
Graphics2D g = (Graphics2D) graphics;
Calendar cal=Calendar.getInstance();
int s =cal.get(Calendar.SECOND) ;
int m =cal.get(Calendar.MINUTE) ;
int h =cal.get(Calendar.HOUR) ;
int ms = m * 60;
int hs = h * 60 * 60;
//Below line of code will draw a circle
Color c=new Color(18, 146, 235);
g.setColor(c);
g.setStroke(MIN_STROKE);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g.drawOval(3,2,111,111);
g.fillOval(3,2,111,111);
cenx=(116)/2;
ceny=(115)/2;
int sr=(110-7)/2;
//Below line of code will draw a second hand
g.setColor(Color.black);
int sxx = (int) ((Math.cos((s * sda) - sa) * sr) + cenx);
int syy = (int) ((Math.sin((s * sda) - sa) * sr) + ceny);
g.setStroke(SEC_STROKE);
g.drawLine(cenx, ceny, sxx, syy);
//Below line of code will draw a minute hand
int mr=sr-4;
c=new Color(255, 255, 255);
g.setColor(c);
int mx = (int) ((Math.cos(((ms + s) * mda) - sa) * mr) + cenx);
int my = (int) ((Math.sin(((ms + s) * mda) - sa) * mr) + ceny);
g.setStroke(MIN_STROKE);
g.drawLine(cenx, ceny, mx, my);
//Below line of code will draw a hour hand
int hr=sr-14;
g.setColor(Color.black);
int hx = (int) ((Math.cos(((hs + ms + s) * hda) - sa) * hr) + cenx);
int hy = (int) ((Math.sin(((hs + ms + s) * hda) - sa) * hr) + ceny);
g.setStroke(HOUR_STROKE);
g.drawLine(cenx, ceny, hx, hy);
//Below line of code will print the Date contents
mday=""+cal.get(Calendar.DAY_OF_MONTH);
wday=cal.get(Calendar.DAY_OF_WEEK);
month=cal.get(Calendar.MONTH);
year=""+cal.get(Calendar.YEAR);
month++;
if(wday==1)
{
swday="Sunday";
}else if(wday==2)
{
swday="Monday";
}else if(wday==3)
{
swday="Tuesday";
}else if(wday==4)
{
swday="Wednesday";
}else if(wday==5)
{
swday="Thursday";
}else if(wday==6)
{
swday="Friday";
}else if(wday==7)
{
swday="Saturday";
}
if(month==1)
{
smonth="Jan";
}else if(month==2)
{
smonth="Feb";
}else if(month==3)
{
smonth="March";
}else if(month==4)
{
smonth="April";
}else if(month==5)
{
smonth="May";
}else if(month==6)
{
smonth="June";
}else if(month==7)
{
smonth="July";
}else if(month==8)
{
smonth="Aug";
}else if(month==9)
{
smonth="Sep";
}else if(month==10)
{
smonth="Oct";
}else if(month==11)
{
smonth="Nov";
}else if(month==12)
{
smonth="Dec";
}
Font f=new Font("Verdana",Font.BOLD,15);
g.setFont(f);
g.setColor(Color.white);
int len_swday=swday.length();
int len_mday=mday.length();
int len_smonth=smonth.length();
int len_year=year.length();
int tot_char=10;
int ycord=140;
float xcord=(118/2)-((len_swday/2)*(118/tot_char));
g.drawString(swday,xcord,ycord);
xcord=(float)((118 / 2) - ((len_mday/ 2) * (118 / tot_char)));
ycord=ycord+15;
g.drawString(mday, xcord,ycord);
xcord=(118/2)-((len_smonth/2)*(118/tot_char));
ycord=ycord+15;
g.drawString(smonth,xcord,ycord);
xcord=(118/2)-((len_year/2)*(118/tot_char));
ycord=ycord+15;
g.drawString(year,xcord,ycord);
f=new Font("Verdana",Font.BOLD,9);
g.setFont(f);
String name="[RK]";
ycord=90;
xcord=(110/2)-((name.length()/3)*(110/tot_char));
g.drawString(name,xcord,ycord);
ycord=15;
}
public static void main(String rk[])
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e){}
AnalogClock clock = new AnalogClock();
}
}
JAVA SERVLET CODE TO DOWNLOAD A .txt file
/*
* RK
*
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author rushabh
*/
public class DownloadFile extends HttpServlet {
protected synchronized void processRequest(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String filePath=request.getParameter("filePath");
System.out.println("filePath = "+filePath);
String fileName="file1";
if(filePath == null)return;
if(filePath.contains("/")){
String[] b = filePath.split("/");
fileName=b[b.length-1];
}
response.setHeader("Content-Length", String.valueOf(new File(filePath).length()));
response.setContentType( "application/octet-stream" );
//response.setContentType("application/vnd.ms-excel");
// System.out.println(".......response.getContentType() = "+response.getContentType());
response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
FileInputStream inputStream = null;
try
{
inputStream = new FileInputStream(filePath);
System.out.println(" INPUTSTREAM CREATED");
byte[] buffer = new byte[1024];
int bytesRead = 0;
do{
bytesRead = inputStream.read(buffer, 0, buffer.length);
response.getOutputStream().write(buffer);
}while (bytesRead == buffer.length);
System.out.println(" END OF WHILE");
response.getOutputStream().flush();
System.out.println(" FLUSHING DONE");
}catch(Exception e){
System.out.println("Exception in DownloadFile.java ="+e);
}finally{
if(inputStream != null)
inputStream.close();
System.out.println(" INPUT STREAM CLOSED");
}
}
//
/**
* Handles the HTTP
GET
method.* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
POST
method.* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}//
}
Monday, July 25, 2011
G+ CROSSING 20 MILLION CONNECTIONS
Google Plus was on June 28th with limited invited users. people were thinking Google will have a hard time to face Facebook and Twitter. but users are migrate to this new network. this new G+ network reached to new milestone , it is crossing 20 million connections since the release date. This is a great achievement given that the project is still in the beta stage and works on an invite-based system.
MOZILLA IS MAKING MOBILE OPERATING SYSTEM
Mozilla's idea is about to take the Gecko engine that drives the FIREFOX browser, they turn it into an open-source operating system that will eventually work on phones and tablets.
Called Boot to Gecko, it is known that the source code will be released to the public "in real-time," wrote Andreas Gal, a Mozilla researcher. Gecko is the rendering engine that powers Firefox and the e-mail client Thunderbird.
It will include some low level android code for driver support so it can run on android devices.
CODE TO SORT GENERIC LIST IN JAVA
List
/*
Assume above line will give store few Student objects in allStudents list so, here below code will sort all the Student objects in allStudents respective to firstname attribute
*/
Collections.sort(allStudents, new Comparator() {
public int compare(Object o1, Object o2) {
Student s1 = (Student)o1;
Student s2 = (Student)o2;
String f1 = s1.getFirstName();
String f2 = s2.getFirstName();
return f1.trim().compareToIgnoreCase(f2.trim());
}
});
for(Student studObj:allStudents) {
out.println(" FirstName : "+studObj.getFirstName());
out.println(" LastName : "+studObj.getLastName());
...........
...........
}
Sunday, July 24, 2011
GMAIL'S PHONE CALL FEATURE
Gmail's phone call feature lets you make calls to other Gmail users as well as to regular cell phones and landlines. Calls to the U.S. and Canada are free, while calls abroad typically cost a few pennies per minute. The feature even includes video chatting.
Until now, you could only make one phone call at a time. But in a recent update to the service, Google has added the ability to make multiple phone calls.
NICE JAVA CODE TO SHOW CLOCK IN INDIA'S FLAG COLORS
import java.util.Calendar;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
*
* @author RK
*/
public class ClockFrame extends javax.swing.JFrame implements Runnable
{
/** Creates new form ClockFrame */
Calendar cal=null;
Thread thr=null;
private int INFORMATION_MESSAGE=1;
public ClockFrame()
{
this.setUndecorated(true);
this.setResizable(false);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
this.setSize(220,300);
initComponents();
cal=Calendar.getInstance();
Hour.setMinorTickSpacing(1);
Hour.setBorder(BorderFactory.createTitledBorder("Hours"));
Hour.setMajorTickSpacing(1);
Hour.setPaintTicks(true);
Hour.setPaintLabels(true);
//Minute=new JSlider(0,59,5);
Minute.setBorder(BorderFactory.createTitledBorder("Minutes"));
Minute.setMajorTickSpacing(5);
Minute.setMinorTickSpacing(1);
Minute.setPaintTicks(true);
Minute.setPaintLabels(true);
Minute.getLabelTable().put(new Integer(59),new JLabel(new Integer(59).toString(), JLabel.CENTER));
Minute.setLabelTable( Minute.getLabelTable() );
Second.setBorder(BorderFactory.createTitledBorder("Seconds"));
Second.setMajorTickSpacing(5);
Second.setMinorTickSpacing(1);
Second.setPaintTicks(true);
Second.setPaintLabels(true);
Second.getLabelTable().put(new Integer(59),new JLabel(new Integer(59).toString(), JLabel.CENTER));
Second.setLabelTable( Second.getLabelTable() );
by.setToolTipText("rajkirpal.er@live.com");
thr=new Thread(this,"TIME");
thr.start();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {
Hour = new javax.swing.JSlider();
Minute = new javax.swing.JSlider();
Second = new javax.swing.JSlider();
FullDate = new javax.swing.JLabel();
WeekDay = new javax.swing.JLabel();
SpHr = new javax.swing.JSpinner();
SpMn = new javax.swing.JSpinner();
SpSc = new javax.swing.JSpinner();
by = new javax.swing.JLabel();
am_pm = new javax.swing.JLabel();
close = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
Hour.setBackground(new java.awt.Color(255, 153, 0));
Hour.setForeground(new java.awt.Color(0, 0, 0));
Hour.setMajorTickSpacing(1);
Hour.setMaximum(12);
Hour.setMinimum(1);
Hour.setMinorTickSpacing(1);
Hour.setOrientation(javax.swing.JSlider.VERTICAL);
Hour.setPaintLabels(true);
Hour.setPaintTicks(true);
Hour.setSnapToTicks(true);
Hour.setValue(1);
Hour.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
getContentPane().add(Hour);
Hour.setBounds(20, 10, 60, 200);
Minute.setBackground(new java.awt.Color(255, 255, 255));
Minute.setMajorTickSpacing(5);
Minute.setMaximum(59);
Minute.setMinorTickSpacing(1);
Minute.setOrientation(javax.swing.JSlider.VERTICAL);
Minute.setPaintLabels(true);
Minute.setPaintTicks(true);
Minute.setSnapToTicks(true);
Minute.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
getContentPane().add(Minute);
Minute.setBounds(80, 10, 60, 200);
Second.setBackground(new java.awt.Color(102, 153, 0));
Second.setMajorTickSpacing(5);
Second.setMaximum(59);
Second.setMinorTickSpacing(1);
Second.setOrientation(javax.swing.JSlider.VERTICAL);
Second.setPaintLabels(true);
Second.setPaintTicks(true);
Second.setSnapToTicks(true);
Second.setValue(1);
Second.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
getContentPane().add(Second);
Second.setBounds(140, 10, 60, 200);
FullDate.setFont(new java.awt.Font("Arial", 0, 14));
FullDate.setText(":");
getContentPane().add(FullDate);
FullDate.setBounds(130, 250, 70, 17);
WeekDay.setFont(new java.awt.Font("Arial", 0, 14));
WeekDay.setText(":");
getContentPane().add(WeekDay);
WeekDay.setBounds(30, 250, 90, 14);
getContentPane().add(SpHr);
SpHr.setBounds(30, 220, 40, 20);
getContentPane().add(SpMn);
SpMn.setBounds(70, 220, 40, 20);
getContentPane().add(SpSc);
SpSc.setBounds(110, 220, 40, 20);
by.setText(" By R.K");
getContentPane().add(by);
by.setBounds(140, 270, 80, 14);
am_pm.setText(":");
getContentPane().add(am_pm);
am_pm.setBounds(160, 220, 60, 20);
close.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
close.setForeground(new java.awt.Color(255, 0, 0));
close.setText(" X");
close.setToolTipText("CLOSE");
close.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
closeMouseClicked(evt);
}
});
getContentPane().add(close);
close.setBounds(0, 260, 20, 30);
pack();
}// //GEN-END:initComponents
private void closeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_closeMouseClicked
// TODO add your handling code here:
this.dispose();
System.exit(0);
}//GEN-LAST:event_closeMouseClicked
/**
* @param RK the command line arguments
*/
public static void main(String RK[]) {
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{}
ClockFrame win=new ClockFrame();
win.setLocation(550, 05);
win.setSize(220,290);
win.setVisible(true);
win.setTitle("STRIPE CLOCK");
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel FullDate;
private javax.swing.JSlider Hour;
private javax.swing.JSlider Minute;
private javax.swing.JSlider Second;
private javax.swing.JSpinner SpHr;
private javax.swing.JSpinner SpMn;
private javax.swing.JSpinner SpSc;
private javax.swing.JLabel WeekDay;
private javax.swing.JLabel am_pm;
public javax.swing.JLabel by;
private javax.swing.JLabel close;
// End of variables declaration//GEN-END:variables
@SuppressWarnings("static-access")
public void run()
{
try
{
while(true)
{
thr.sleep(100);
cal=Calendar.getInstance();
int hr=cal.get(Calendar.HOUR);
int min=cal.get(Calendar.MINUTE);
int sec=cal.get(Calendar.SECOND);
int ampm=cal.get(Calendar.AM_PM);
if(ampm==0)
{
am_pm.setText("AM");
}
else
{
am_pm.setText("PM");
}
if(hr==0)
{
hr=12;
}
Hour.setValue(hr);
Minute.setValue(min);
Second.setValue(sec);
SpHr.setValue(hr);
SpMn.setValue(min);
SpSc.setValue(sec);
int day=cal.get(Calendar.DAY_OF_MONTH);
int month=cal.get(Calendar.MONTH);
int year=cal.get(Calendar.YEAR);
int weekday=cal.get(Calendar.DAY_OF_WEEK);
switch(weekday)
{
case 1:
WeekDay.setText("Sunday");
break;
case 2:
WeekDay.setText("Monday");
break;
case 3:
WeekDay.setText("Tuesday");
break;
case 4:
WeekDay.setText("Wednesday");
break;
case 5:
WeekDay.setText("Thursday");
break;
case 6:
WeekDay.setText("Friday");
break;
case 7:
WeekDay.setText("Saturday");
break;
default:
break;
}
FullDate.setText(day+"/"+month+"/"+year);
}
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,"ERROR WHILE RTRIEVING TIME INFORMATION","ERROR",INFORMATION_MESSAGE);
}
}
}
Friday, July 22, 2011
NOW APPLE LEADS NOKIA IN SMARTPHONE SALES
With Nokia's company earnings call now behind us, one of the most startling figures indicative of the decline of the mobile phone maker was this: for the first time ever, the Apple iPhone surpassed Nokia in smartphone sales.
Nokia says it sold 16.7 million smartphones in the previous quarter (April through June). During that same time, Apple sold over 20 million iPhones.
Thursday, July 21, 2011
NASA : Atlantis lands : End of shuttle era
Emotions ran high at NASA as the crew of four astronauts returned to Earth after a 12-day mission. Before landing, Atlantis commander Chris Ferguson recalled his memory of Neil Armstrong walking on the moon in 1969, while imparting his thoughts to NASA flight controllers about the shuttle's historic last flight. "Forty-two years ago today, Neil Armstrong walked on the moon, and I consider myself fortunate that I was there to actually remember the event," Ferguson told mission contro
Wednesday, July 20, 2011
INTEL, A NEW FACE OF COMPUTING
SAN FRANCISCO (AP) — The changing face of the computer industry was on display Wednesday as two companies representing the old guard and the new issued strong results for the latest quarter.
Intel, a bedrock of the PC business, and Qualcomm, a vanguard in mobile computing, showed how companies at opposite ends of the computing spectrum are adapting to a market that's in intense upheaval.
The U.S. and European PC markets have slumped: Fewer people are buying new PCs because of economic anxiety, market saturation and the rise of seductive new gadgets such as Apple's iPad.
So Intel, which helped create the PC industry three decades ago, is counting on other areas for growth.
The world's No. 1 maker of PC processors benefited from healthy demand from corporations and in emerging markets. It also rode the popularity of smartphones and tablet computers by selling the chips powering additional servers needed to handle the increased mobile traffic.
BROWSERS STATISTICS FOR LAST 6 MONTHS
2011 Internet Explorer Firefox Chrome Safari Opera
-----------------------------------------------------------------------------------------------------------------------
June 23.2 % 42.2 % 27.9 % 3.7 % 2.4 %
-----------------------------------------------------------------------------------------------------------------------
May 24.9 % 42.4 % 25.9 % 4.0 % 2.4 %
-----------------------------------------------------------------------------------------------------------------------
April 24.3 % 42.9 % 25.6 % 4.1 % 2.6 %
-----------------------------------------------------------------------------------------------------------------------
March 25.8 % 42.2 % 25.0 % 4.0 % 2.5 %
-----------------------------------------------------------------------------------------------------------------------
February 26.5 % 42.4 % 24.1 % 4.1 % 2.5 %
------------------------------------------------------------------------------------------------------------------
January 26.6 % 42.8 % 23.8 % 4.0 % 2.5 %
-----------------------------------------------------------------------------------------------------------------------
June 23.2 % 42.2 % 27.9 % 3.7 % 2.4 %
-----------------------------------------------------------------------------------------------------------------------
May 24.9 % 42.4 % 25.9 % 4.0 % 2.4 %
-----------------------------------------------------------------------------------------------------------------------
April 24.3 % 42.9 % 25.6 % 4.1 % 2.6 %
-----------------------------------------------------------------------------------------------------------------------
March 25.8 % 42.2 % 25.0 % 4.0 % 2.5 %
-----------------------------------------------------------------------------------------------------------------------
February 26.5 % 42.4 % 24.1 % 4.1 % 2.5 %
------------------------------------------------------------------------------------------------------------------
January 26.6 % 42.8 % 23.8 % 4.0 % 2.5 %
Tuesday, July 19, 2011
JAVA CODE TO DETECT USB PORT [PEN DRIVE] AND DISPLAY ITS CONTENTS
import java.io.*;
class PenDrive implements Runnable
{
public PenDrive()
{
}
}
public class FindDrive
{
public static void main(String[] RK)
{
String[] letters = new String[]{ "A", "B", "C", "D", "E", "F", "G", "H", "I"};
File[] drives = new File[letters.length];
boolean[] isDrive = new boolean[letters.length];
int totFiles=0,totDirs=0;
// init the file objects and the initial drive state
for ( int i = 0; i < letters.length; ++i )
{
drives[i] = new File(letters[i]+":/");
isDrive[i] = drives[i].canRead();
}
System.out.println("FindDrive: waiting for devices...");
while(true)
{
// check each drive
for ( int i = 0; i < letters.length; ++i )
{
boolean pluggedIn = drives[i].canRead();
// if the state has changed output a message
if ( pluggedIn != isDrive[i] )
{
if ( pluggedIn )
{
String path=letters[i]+"://";
File files=new File(path);
String allFiles[]=files.list();
for(int k=0; k
File f=new File(path+"/"+allFiles[k]);
if(f.isDirectory())
{
totDirs++;
System.out.println("Directory :"+allFiles[k]);
}
else
{
totFiles++;
System.out.println("File :"+allFiles[k]);
}
}
System.out.println("Total Directories and Files :"+allFiles.length);
System.out.println("Total Directories :"+allFiles.length);
System.out.println("Total Files :"+allFiles.length);
}
else
{
System.out.println("Drive "+letters[i]+" has been unplugged");
}
isDrive[i] = pluggedIn;
}
}
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{ }
}
}
}
Thank You.
MUST READ : J2EE ESSENTIAL DEFINITIONS
J2EE ESSENTIALS
J2EE specification defines the following J2EE components:
• Application clients and applets are components that run on the client.
• Java Servlet and JavaServer Pages™ (JSP™) technology
components are web components that run on the server.
• Enterprise JavaBeans™ (EJB™) components (enterprise beans)
are business components that run on the server.
J2EE Clients
A J2EE client can be a web client or an application client.
Web Clients
A web client consists of two parts: (1) dynamic web pages containing various types of markup language (HTML, XML, and so on), which are generated by web components running in the web tier, and (2) a web browser, which renders the pages received from the server. A web client is sometimes called a thin client. Thin clients usually do not query databases, execute complex business rules, or connect to legacy applications. When you use a thin client, such heavyweight operations are off-loaded to enterprise beans executing on the J2EE server, where they can leverage the security, speed, services, and reliability of J2EE server-side technologies.
Applets
An applet is a small client application written in the Java programming language that executes in the Java virtual machine installed in the web browser.
Web Components
J2EE web components are either servlets or pages created using JSP technology (JSP pages). Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content.
Business Components
Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier.
There are three kinds of enterprise beans: session beans, entity beans, and message- driven beans. A session bean represents a transient conversation with a client.When the client finishes executing, the session bean and its data are gone. In contrast, an entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services
ensure that the entity bean data is saved. A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS messages asynchronously.
Enterprise Information System Tier
The enterprise information system tier handles EIS software and includes enterprise infrastructure systems such as enterprise resource planning (ERP), mainframe transaction processing, database systems, and other legacy information systems.
Container Types
J2EE server
The runtime portion of a J2EE product. A J2EE server provides EJB and
web containers.
Enterprise JavaBeans (EJB) container
Manages the execution of enterprise beans for J2EE applications. Enterprise beans and their container run on the J2EE server.
Web container
Manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server.
Application client container
Manages the execution of application client components. Application clients and their container run on the client.
Applet container
Manages the execution of applets. Consists of a web browser and Java Plugin running on the client together.
SOAP Transport Protocol
Client requests and web service responses are transmitted as Simple Object Access Protocol (SOAP) messages over HTTP to enable a completely interoperable exchange between clients and web services, all running on different platforms and at various locations on the Internet.
WSDL Standard Format
TheWeb Services Description Language (WSDL) is a standardized XML format for describing network services. The description includes the name of the service, the location of the service, and ways to communicate with the service.
UDDI and ebXML Standard Formats
Other XML-based standards, such as Universal Description, Discovery and Integration (UDDI) and ebXML, make it possible for businesses to publish information on the Internet about their products and web services, where the information can be readily and globally accessed by clients who want to do business.
Packaging Applications
A J2EE application is delivered in an Enterprise Archive (EAR) file, a standard Java Archive (JAR) file with an .ear extension. Using EAR files and modules makes it possible to assemble a number of different J2EE applications using some of the same components. No extra coding is needed; it is only a matter of assembling (or packaging) various J2EE modules into J2EE EAR files. An EAR file (see Figure 1–6) contains J2EE modules and deployment descriptors.
A deployment descriptor is an XML document with an .xml extension that
describes the deployment settings of an application, a module, or a component. Because deployment descriptor information is declarative, it can be changed without the need to modify the source code. At runtime, the J2EE server reads the deployment descriptor and acts upon the application, module, or component accordingly.
J2EE Product Provider
The J2EE product provider is the company that designs and makes available for purchase the J2EE platform APIs, and other features defined in the J2EE specification.
Tool Provider
The tool provider is the company or person who creates development, assembly, and packaging tools used by component providers, assemblers, and deployers.
Application Component Provider
The application component provider is the company or person who creates web components, enterprise beans, applets, or application clients for use in J2EE applications.
Enterprise Bean Developer
An enterprise bean developer performs the following tasks to deliver an EJB JAR file that contains the enterprise bean(s):
• Writes and compiles the source code
• Specifies the deployment descriptor
• Packages the .class files and deployment descriptor into the EJB JAR file
Web Component Developer
A web component developer performs the following tasks to deliver a WAR file containing the web component(s):
• Writes and compiles servlet source code
• Writes JSP and HTML files
• Specifies the deployment descriptor
• Packages the .class, .jsp, and.html files and deployment descriptor into
the WAR file
Application Assembler
The application assembler is the company or person who receives application modules from component providers and assembles them into a J2EE application EAR file.
Application Deployer and Administrator
The application deployer and administrator is the company or person who configures and deploys the J2EE application, administers the computing and networking infrastructure where J2EE applications run, and oversees the runtime environment. Duties include such things as setting transaction controls and security attributes and specifying connections to databases.
A deployer or system administrator performs the following tasks to install and configure a J2EE application:
• Adds the J2EE application (EAR) file created in the preceding phase to
the J2EE server
• Configures the J2EE application for the operational environment by
modifying the deployment descriptor of the J2EE application
• Verifies that the contents of the EAR file are well formed and comply with
the J2EE specification
• Deploys (installs) the J2EE application EAR file into the J2EE server
Enterprise JavaBeans Technology
An Enterprise JavaBeans™ (EJB™) component, or enterprise bean, is a body of code having fields and methods to implement modules of business logic. You can think of an enterprise bean as a building block that can be used alone or with other enterprise beans to execute business logic on the J2EE server.
Web container Web components are supported by the services of a runtime platform called a web container. A web container provides services such as request dispatching, security, concurrency, and life-cycle management. It also gives web components access to APIs such as naming,transactions, and email.
Java EE server: The runtime portion of a Java EE product. A Java EE server provides EJB and web containers
Java Servlet Technology
Java servlet technology lets you define HTTP-specific servlet classes. A servlet class extends the capabilities of servers that host applications that are accessed by way of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers.
JavaServer Pages Technology
JavaServer Pages™ (JSP™) technology lets you put snippets of servlet code directly into a text-based document. A JSP page is a text-based document that contains two types of text: static data (which can be expressed in any text-based format such as HTML, WML, and XML)
Java Message Service API
The Java Message Service (JMS) API is a messaging standard that allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.
Java Transaction API
The Java Transaction API (JTA) provides a standard interface for demarcating transactions. The J2EE architecture provides a default auto commit to handle transaction commits and rollbacks. An auto commit means that any other applications that are viewing data will see the updated data after each database read or
write operation.
Java Naming and Directory Interface
The Java Naming and Directory Interface™ (JNDI) provides naming and directory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a J2EE application can store and retrieve any type of named Java object.
JavaServer Faces
JavaServer Faces technology is a user interface framework for building web applications.
A GUI component framework.
The following features support the GUI components:
• Input validation
• Event handling
• Data conversion between model objects and components
• Managed model object creation
• Page navigation configuration
What are Web Services?
Web services are application components
Web services communicate using open protocols
Web services are self-contained and self-describing
Web services can be discovered using UDDI
Web services can be used by other applications
XML is the basis for Web services
How Does it Work?
The basic Web services platform is XML + HTTP.
XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions.
The HTTP protocol is the most used Internet protocol.
Web services platform elements:
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
A few years ago Web services were not fast enough to be interesting.
Interoperability has Highest Priority
When all major platforms could access the Web using Web browsers, different platforms could interact. For these platforms to work together, Web-applications were developed.
Web-applications are simple applications that run on the web. These are built around the Web browser standards and can be used by any browser on any platform.
Web Services take Web-applications to the Next Level
By using Web services, your application can publish its function or message to the rest of the world.
Web services use XML to code and to decode data, and SOAP to transport it (using open protocols).
With Web services, your accounting department's Win 2k server's billing system can connect with your IT supplier's UNIX server.
Web Services have Two Types of Uses
Reusable application-components.
There are things applications need very often. So why make these over and over again?
Web services can offer application-components like: currency conversion, weather reports, or even language translation as services.
Connect existing software.
Web services can help to solve the interoperability problem by giving different applications a way to link their data.
With Web services you can exchange data between different applications and different platforms.
What is SOAP?
SOAP is an XML-based protocol to let applications exchange information over HTTP.
Or more simple: SOAP is a protocol for accessing a Web Service.
SOAP stands for Simple Object Access Protocol
SOAP is a communication protocol
SOAP is a format for sending messages
SOAP is designed to communicate via Internet
SOAP is platform independent
SOAP is language independent
SOAP is based on XML
SOAP is simple and extensible
SOAP allows you to get around firewalls
SOAP is a W3C standard
What is WSDL?
WSDL is an XML-based language for locating and describing Web services.
WSDL stands for Web Services Description Language
WSDL is based on XML
WSDL is used to describe Web services
WSDL is used to locate Web services
WSDL is a W3C standard
What is UDDI?
UDDI is a directory service where companies can register and search for Web services.
UDDI stands for Universal Description, Discovery and Integration
UDDI is a directory for storing information about web services
UDDI is a directory of web service interfaces described by WSDL
UDDI communicates via SOAP
UDDI is built into the Microsoft .NET platform
Thanks @ Regards
RK
http://rkj2me.blogspot.com
J2EE specification defines the following J2EE components:
• Application clients and applets are components that run on the client.
• Java Servlet and JavaServer Pages™ (JSP™) technology
components are web components that run on the server.
• Enterprise JavaBeans™ (EJB™) components (enterprise beans)
are business components that run on the server.
J2EE Clients
A J2EE client can be a web client or an application client.
Web Clients
A web client consists of two parts: (1) dynamic web pages containing various types of markup language (HTML, XML, and so on), which are generated by web components running in the web tier, and (2) a web browser, which renders the pages received from the server. A web client is sometimes called a thin client. Thin clients usually do not query databases, execute complex business rules, or connect to legacy applications. When you use a thin client, such heavyweight operations are off-loaded to enterprise beans executing on the J2EE server, where they can leverage the security, speed, services, and reliability of J2EE server-side technologies.
Applets
An applet is a small client application written in the Java programming language that executes in the Java virtual machine installed in the web browser.
Web Components
J2EE web components are either servlets or pages created using JSP technology (JSP pages). Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content.
Business Components
Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier.
There are three kinds of enterprise beans: session beans, entity beans, and message- driven beans. A session bean represents a transient conversation with a client.When the client finishes executing, the session bean and its data are gone. In contrast, an entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services
ensure that the entity bean data is saved. A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS messages asynchronously.
Enterprise Information System Tier
The enterprise information system tier handles EIS software and includes enterprise infrastructure systems such as enterprise resource planning (ERP), mainframe transaction processing, database systems, and other legacy information systems.
Container Types
J2EE server
The runtime portion of a J2EE product. A J2EE server provides EJB and
web containers.
Enterprise JavaBeans (EJB) container
Manages the execution of enterprise beans for J2EE applications. Enterprise beans and their container run on the J2EE server.
Web container
Manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server.
Application client container
Manages the execution of application client components. Application clients and their container run on the client.
Applet container
Manages the execution of applets. Consists of a web browser and Java Plugin running on the client together.
SOAP Transport Protocol
Client requests and web service responses are transmitted as Simple Object Access Protocol (SOAP) messages over HTTP to enable a completely interoperable exchange between clients and web services, all running on different platforms and at various locations on the Internet.
WSDL Standard Format
TheWeb Services Description Language (WSDL) is a standardized XML format for describing network services. The description includes the name of the service, the location of the service, and ways to communicate with the service.
UDDI and ebXML Standard Formats
Other XML-based standards, such as Universal Description, Discovery and Integration (UDDI) and ebXML, make it possible for businesses to publish information on the Internet about their products and web services, where the information can be readily and globally accessed by clients who want to do business.
Packaging Applications
A J2EE application is delivered in an Enterprise Archive (EAR) file, a standard Java Archive (JAR) file with an .ear extension. Using EAR files and modules makes it possible to assemble a number of different J2EE applications using some of the same components. No extra coding is needed; it is only a matter of assembling (or packaging) various J2EE modules into J2EE EAR files. An EAR file (see Figure 1–6) contains J2EE modules and deployment descriptors.
A deployment descriptor is an XML document with an .xml extension that
describes the deployment settings of an application, a module, or a component. Because deployment descriptor information is declarative, it can be changed without the need to modify the source code. At runtime, the J2EE server reads the deployment descriptor and acts upon the application, module, or component accordingly.
J2EE Product Provider
The J2EE product provider is the company that designs and makes available for purchase the J2EE platform APIs, and other features defined in the J2EE specification.
Tool Provider
The tool provider is the company or person who creates development, assembly, and packaging tools used by component providers, assemblers, and deployers.
Application Component Provider
The application component provider is the company or person who creates web components, enterprise beans, applets, or application clients for use in J2EE applications.
Enterprise Bean Developer
An enterprise bean developer performs the following tasks to deliver an EJB JAR file that contains the enterprise bean(s):
• Writes and compiles the source code
• Specifies the deployment descriptor
• Packages the .class files and deployment descriptor into the EJB JAR file
Web Component Developer
A web component developer performs the following tasks to deliver a WAR file containing the web component(s):
• Writes and compiles servlet source code
• Writes JSP and HTML files
• Specifies the deployment descriptor
• Packages the .class, .jsp, and.html files and deployment descriptor into
the WAR file
Application Assembler
The application assembler is the company or person who receives application modules from component providers and assembles them into a J2EE application EAR file.
Application Deployer and Administrator
The application deployer and administrator is the company or person who configures and deploys the J2EE application, administers the computing and networking infrastructure where J2EE applications run, and oversees the runtime environment. Duties include such things as setting transaction controls and security attributes and specifying connections to databases.
A deployer or system administrator performs the following tasks to install and configure a J2EE application:
• Adds the J2EE application (EAR) file created in the preceding phase to
the J2EE server
• Configures the J2EE application for the operational environment by
modifying the deployment descriptor of the J2EE application
• Verifies that the contents of the EAR file are well formed and comply with
the J2EE specification
• Deploys (installs) the J2EE application EAR file into the J2EE server
Enterprise JavaBeans Technology
An Enterprise JavaBeans™ (EJB™) component, or enterprise bean, is a body of code having fields and methods to implement modules of business logic. You can think of an enterprise bean as a building block that can be used alone or with other enterprise beans to execute business logic on the J2EE server.
Web container Web components are supported by the services of a runtime platform called a web container. A web container provides services such as request dispatching, security, concurrency, and life-cycle management. It also gives web components access to APIs such as naming,transactions, and email.
Java EE server: The runtime portion of a Java EE product. A Java EE server provides EJB and web containers
Java Servlet Technology
Java servlet technology lets you define HTTP-specific servlet classes. A servlet class extends the capabilities of servers that host applications that are accessed by way of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers.
JavaServer Pages Technology
JavaServer Pages™ (JSP™) technology lets you put snippets of servlet code directly into a text-based document. A JSP page is a text-based document that contains two types of text: static data (which can be expressed in any text-based format such as HTML, WML, and XML)
Java Message Service API
The Java Message Service (JMS) API is a messaging standard that allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.
Java Transaction API
The Java Transaction API (JTA) provides a standard interface for demarcating transactions. The J2EE architecture provides a default auto commit to handle transaction commits and rollbacks. An auto commit means that any other applications that are viewing data will see the updated data after each database read or
write operation.
Java Naming and Directory Interface
The Java Naming and Directory Interface™ (JNDI) provides naming and directory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a J2EE application can store and retrieve any type of named Java object.
JavaServer Faces
JavaServer Faces technology is a user interface framework for building web applications.
A GUI component framework.
The following features support the GUI components:
• Input validation
• Event handling
• Data conversion between model objects and components
• Managed model object creation
• Page navigation configuration
What are Web Services?
Web services are application components
Web services communicate using open protocols
Web services are self-contained and self-describing
Web services can be discovered using UDDI
Web services can be used by other applications
XML is the basis for Web services
How Does it Work?
The basic Web services platform is XML + HTTP.
XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions.
The HTTP protocol is the most used Internet protocol.
Web services platform elements:
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
A few years ago Web services were not fast enough to be interesting.
Interoperability has Highest Priority
When all major platforms could access the Web using Web browsers, different platforms could interact. For these platforms to work together, Web-applications were developed.
Web-applications are simple applications that run on the web. These are built around the Web browser standards and can be used by any browser on any platform.
Web Services take Web-applications to the Next Level
By using Web services, your application can publish its function or message to the rest of the world.
Web services use XML to code and to decode data, and SOAP to transport it (using open protocols).
With Web services, your accounting department's Win 2k server's billing system can connect with your IT supplier's UNIX server.
Web Services have Two Types of Uses
Reusable application-components.
There are things applications need very often. So why make these over and over again?
Web services can offer application-components like: currency conversion, weather reports, or even language translation as services.
Connect existing software.
Web services can help to solve the interoperability problem by giving different applications a way to link their data.
With Web services you can exchange data between different applications and different platforms.
What is SOAP?
SOAP is an XML-based protocol to let applications exchange information over HTTP.
Or more simple: SOAP is a protocol for accessing a Web Service.
SOAP stands for Simple Object Access Protocol
SOAP is a communication protocol
SOAP is a format for sending messages
SOAP is designed to communicate via Internet
SOAP is platform independent
SOAP is language independent
SOAP is based on XML
SOAP is simple and extensible
SOAP allows you to get around firewalls
SOAP is a W3C standard
What is WSDL?
WSDL is an XML-based language for locating and describing Web services.
WSDL stands for Web Services Description Language
WSDL is based on XML
WSDL is used to describe Web services
WSDL is used to locate Web services
WSDL is a W3C standard
What is UDDI?
UDDI is a directory service where companies can register and search for Web services.
UDDI stands for Universal Description, Discovery and Integration
UDDI is a directory for storing information about web services
UDDI is a directory of web service interfaces described by WSDL
UDDI communicates via SOAP
UDDI is built into the Microsoft .NET platform
Thanks @ Regards
RK
http://rkj2me.blogspot.com
Monday, July 18, 2011
JAVA CODE TO STORE AND RETRIEVE IMAGE IN DATABASE
///////////////////////////////////////////////////////
import java.sql.*;
import java.io.*;
class MySqlSaveImage
{
public static void main(String[] RK) throws SQLException
{
Connection connection = null;
String connectionURL = "jdbc:mysql://localhost:3306/mydb";
ResultSet rs = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try {
Class.forName("com.mysql.jdbc.Driver");//.newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "magnet");
File image = new File("c:/Me.jpg");
psmnt = connection.prepareStatement("insert into images(image) "+ "values(?)");
fis = new FileInputStream(image);
psmnt.setBinaryStream(1, (InputStream)fis, (int)(image.length()));
int flag= psmnt.executeUpdate();
if(flag>0)
{
System.out.println("Uploaded successfully !");
}
else
{
System.out.println("unsucessfull to upload image.");
}
}
catch (Exception ex)
{
System.out.println("Found some error : "+ex);
}
finally
{
connection.close();
psmnt.close();
}
}
}
///////////////////////////////////////////////////////////////
import java.sql.*;
import java.io.*;
public class MysqlRetrieveImage
{
public static void main(String[] rk)
{
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
InputStream in=null;
OutputStream out=null;
String getImg=null;
int len=0,i,count=1,index=0;
Blob bl=null;
try
{
Class.forName("com.mysql.jdbc.Driver");//.newInstance();
con=DriverManager.getConnection("jdbc:mysql://localhost/mydb","root","magnet");
stmt=con.createStatement();
rs=stmt.executeQuery("SELECT image FROM IMAGES");
while(rs.next())
{
out = new FileOutputStream("c:/"+count+".jpg");
getImg=rs.getString(1);
System.out.println("getImg length : "+getImg.length());
in =rs.getBinaryStream(1);
byte b[]=new byte[in.available()];
System.out.println("total bytes : "+in.available());
while((index=in.read(b))!=-1)
{
out.write(b,0,index);
}
count++;
}
in.close();
out.close();
System.out.println("Images Retrieved Successfully.....");
}catch(Exception e)
{
System.out.println("Error : "+e);
}
}
}
////////////////////////////////////////////////////////////////////////////////////
/* Copy your MySql Connector .jar file into "C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext" location or set the classpath for the same .jar file*/
/* Create one user into your MySql Server or use the default user name and password (username="root password="root") */
////////////////////////////////////////////////////////////////////////////////////
LEAVE YOUR COMMENTS FRIENDS.
Thank You.
import java.sql.*;
import java.io.*;
class MySqlSaveImage
{
public static void main(String[] RK) throws SQLException
{
Connection connection = null;
String connectionURL = "jdbc:mysql://localhost:3306/mydb";
ResultSet rs = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try {
Class.forName("com.mysql.jdbc.Driver");//.newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "magnet");
File image = new File("c:/Me.jpg");
psmnt = connection.prepareStatement("insert into images(image) "+ "values(?)");
fis = new FileInputStream(image);
psmnt.setBinaryStream(1, (InputStream)fis, (int)(image.length()));
int flag= psmnt.executeUpdate();
if(flag>0)
{
System.out.println("Uploaded successfully !");
}
else
{
System.out.println("unsucessfull to upload image.");
}
}
catch (Exception ex)
{
System.out.println("Found some error : "+ex);
}
finally
{
connection.close();
psmnt.close();
}
}
}
///////////////////////////////////////////////////////////////
import java.sql.*;
import java.io.*;
public class MysqlRetrieveImage
{
public static void main(String[] rk)
{
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
InputStream in=null;
OutputStream out=null;
String getImg=null;
int len=0,i,count=1,index=0;
Blob bl=null;
try
{
Class.forName("com.mysql.jdbc.Driver");//.newInstance();
con=DriverManager.getConnection("jdbc:mysql://localhost/mydb","root","magnet");
stmt=con.createStatement();
rs=stmt.executeQuery("SELECT image FROM IMAGES");
while(rs.next())
{
out = new FileOutputStream("c:/"+count+".jpg");
getImg=rs.getString(1);
System.out.println("getImg length : "+getImg.length());
in =rs.getBinaryStream(1);
byte b[]=new byte[in.available()];
System.out.println("total bytes : "+in.available());
while((index=in.read(b))!=-1)
{
out.write(b,0,index);
}
count++;
}
in.close();
out.close();
System.out.println("Images Retrieved Successfully.....");
}catch(Exception e)
{
System.out.println("Error : "+e);
}
}
}
////////////////////////////////////////////////////////////////////////////////////
/* Copy your MySql Connector .jar file into "C:\Program Files\Java\jdk1.6.0_06\jre\lib\ext" location or set the classpath for the same .jar file*/
/* Create one user into your MySql Server or use the default user name and password (username="root password="root") */
////////////////////////////////////////////////////////////////////////////////////
LEAVE YOUR COMMENTS FRIENDS.
Thank You.
Judge: It's 'possible' Google knew of Java violation
In reading the Daubert briefing, it appears possible that early on Google recognized that it would infringe patents protecting at least part of Java, entered into negotiations with Sun [Microsystems] to obtain a license for use in Android, then abandoned the negotiations as too expensive, and pushed home with Android without any license at all," Alsup wrote in the letter filed in U.S. District Court for the Northern District of California.
"How accurate is this scenario?" he added. "Does Google acknowledge that Android infringes at least some of the claims if valid? If so, how should this affect the damages analysis? How should this affect the questions of willfulness and equitable relief? Counsel should be prepared to address these issues at the hearing
"How accurate is this scenario?" he added. "Does Google acknowledge that Android infringes at least some of the claims if valid? If so, how should this affect the damages analysis? How should this affect the questions of willfulness and equitable relief? Counsel should be prepared to address these issues at the hearing
JAVA CODE TO ITERATE MAP
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
*
* @author RK
*/
public class MapTest {
public static void main(String RK[]) {
Map mapObj = new HashMap();
mapObj.put(1, "ONE");
mapObj.put(2, "TWO");
Iterator it = mapObj.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
System.out.println(pairs.getKey() + " = " + pairs.getValue());
}
}
}
Friend , leave your commnets. Your comments are heartly invited
import java.util.Iterator;
import java.util.Map;
/**
*
* @author RK
*/
public class MapTest {
public static void main(String RK[]) {
Map
mapObj.put(1, "ONE");
mapObj.put(2, "TWO");
Iterator it = mapObj.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
System.out.println(pairs.getKey() + " = " + pairs.getValue());
}
}
}
Friend , leave your commnets. Your comments are heartly invited
Sunday, July 17, 2011
JAVA CODE TO STORE IMAGE IN DATABASE
import java.sql.*;
import java.io.*;
class MySqlSaveImage
{
public static void main(String[] rk) throws SQLException
{
Connection connection = null;
String connectionURL = "jdbc:mysql://localhost:3306/mydb";
ResultSet rs = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try {
Class.forName("com.mysql.jdbc.Driver");//.newInstance();
connection = DriverManager.getConnection(connectionURL, "username", "password");
File image = new File("c:/Me.jpg");
psmnt = connection.prepareStatement("insert into images(image) "+ "values(?)");
fis = new FileInputStream(image);
psmnt.setBinaryStream(1, (InputStream)fis, (int)(image.length()));
int flag= psmnt.executeUpdate();
if(flag>0)
{
System.out.println("Uploaded successfully !");
}
else
{
System.out.println("unsucessfull to upload image.");
}
}
catch (Exception ex)
{
System.out.println("Found some error : "+ex);
}
finally
{
connection.close();
psmnt.close();
}
}
}
Friend leave your comments. Your comments are heartly invited
import java.io.*;
class MySqlSaveImage
{
public static void main(String[] rk) throws SQLException
{
Connection connection = null;
String connectionURL = "jdbc:mysql://localhost:3306/mydb";
ResultSet rs = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try {
Class.forName("com.mysql.jdbc.Driver");//.newInstance();
connection = DriverManager.getConnection(connectionURL, "username", "password");
File image = new File("c:/Me.jpg");
psmnt = connection.prepareStatement("insert into images(image) "+ "values(?)");
fis = new FileInputStream(image);
psmnt.setBinaryStream(1, (InputStream)fis, (int)(image.length()));
int flag= psmnt.executeUpdate();
if(flag>0)
{
System.out.println("Uploaded successfully !");
}
else
{
System.out.println("unsucessfull to upload image.");
}
}
catch (Exception ex)
{
System.out.println("Found some error : "+ex);
}
finally
{
connection.close();
psmnt.close();
}
}
}
Friend leave your comments. Your comments are heartly invited
Saturday, July 16, 2011
INDIAN FILM STAR'S CHILDHOOLD PHOTOS
AAMIR
AMITABH BACHCHAN
HRITHIK
AKSHAY
AFTAB
ABHISHEK
AMISHA
ASH
URMILA
TWINKLE
TABBU
SUSMITA
SRK
SUNNY
SHILPA
SHAHID
SHRIDEVI
SALMAN FAMILY
SANJAY DUTT
KAREENA
PREITY
MADHURI
KAJOL
KANGNA
ESHA
PRIYANKA
RANI
ASHIN
DEEPIKA
KAMAL HASHAN
AMITABH BACHCHAN
HRITHIK
AKSHAY
AFTAB
ABHISHEK
AMISHA
ASH
URMILA
TWINKLE
TABBU
SUSMITA
SRK
SUNNY
SHILPA
SHAHID
SHRIDEVI
SALMAN FAMILY
SANJAY DUTT
KAREENA
PREITY
MADHURI
KAJOL
KANGNA
ESHA
PRIYANKA
RANI
ASHIN
DEEPIKA
KAMAL HASHAN
Subscribe to:
Posts (Atom)