Pages

Srinivasan chinnasamy

Srinivasan chinnasamy photos




Srinivasan chinnasamy

Srinivasan chinnasamy


how to write pdf file in java simple example


Very Simple methods

But before you start this application you must download iTextpdf related jar(s).

you need to use jar files Click Here 

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class SimplePdf {
   
    public static void main(String[] args) {
       
        try {
            int Count=0;
           
            File myDir=new File("D:/new/files");
            myDir.mkdirs();
            Count++;
            //File file1 = new File(myDir, "filename.pdf");
           
            String fname = "file" + Count + ".pdf";
            File file1 = new File (myDir, fname);
            myDir.mkdirs();
            Count++;
            System.out.println(file1);
       
            System.out.println(Count);
            OutputStream file = new FileOutputStream(file1);
            Document document = new Document();
            PdfWriter.getInstance(document, file);
           
           
            String name="Srini";
            String address="India";
            PdfPTable table=new PdfPTable(2);
            PdfPCell cell = new PdfPCell (new Paragraph ("Beautyton"));
            cell.setColspan (3);
            cell.setHorizontalAlignment (Element.ALIGN_CENTER);
            cell.setPadding (10.0f);
            cell.setBackgroundColor (new BaseColor (140, 221, 8));                                 
            table.addCell(cell);                                     
            table.addCell("Name");
            table.addCell("Address");
            table.addCell(name);
            table.addCell(address);
       
            table.setSpacingBefore(50.0f);       // Space Before table starts, like margin-top in CSS
            table.setSpacingAfter(50.0f);        // Space After table starts, like margin-Bottom in CSS                                         
            document.open();//PDF document opened........                 
            document.add(Chunk.NEWLINE);   //Something like in HTML :-)
            document.add(new Paragraph("Welcome"));
            document.add(new Paragraph("Document Generated On - "+new Date().toString()));   
            document.add(table);
            document.add(Chunk.NEWLINE);   //Something like in HTML :-)                               
            document.close();
            file.close();
            System.out.println("Pdf created successfully..");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

how to file write pdf file in andriod sdcard



Very simple Method And easy

But before you start this application you must download iTextpdf related jar(s).

you need to use jar files Click Here  

The code use in your activity of where you need at position.

try {
              
                OutputStream file = new FileOutputStream(new File("storage/sdcard/file.pdf"));
                Document document = new Document();
                PdfWriter.getInstance(document, file);

                //Inserting Image in PDF
//                Image image = Image.getInstance ("D:/dog.png");
//                image.scaleAbsolute(120f, 60f);//image width,height  

                //Inserting Table in PDF
                ArrayList al = new ArrayList();
                al.add("Name");
                al.add("Address");
          
                PdfPTable table=new PdfPTable(2);

                PdfPCell cell = new PdfPCell (new Paragraph ("Beautyton"));

                cell.setColspan (3);
                cell.setHorizontalAlignment (Element.ALIGN_CENTER);
                cell.setPadding (10.0f);
                cell.setBackgroundColor (new BaseColor (140, 221, 8));                                

                table.addCell(cell);                                    

                table.addCell("Problems");
                table.addCell("Solutions");
              
                for(int i=0;i                {
                    table.addCell(finallist1.get(i));// filallist1 is arraylist
                    table.addCell(finallist.get(i));// filallist is arraylist
                  
                }
                table.setSpacingBefore(50.0f);       // Space Before table starts, like margin-top in CSS
                table.setSpacingAfter(50.0f);        // Space After table starts, like margin-Bottom in CSS                                        

                //Now Insert Every Thing Into PDF Document
                document.open();//PDF document opened........                

                document.add(Chunk.NEWLINE);   //Something like in HTML :-)

                document.add(new Paragraph("Welcome"));
                document.add(new Paragraph("Document Generated On - "+new Date(mImageCount).toString()));  

                document.add(table);

                document.add(Chunk.NEWLINE);   //Something like in HTML :-)                              
                document.close();
                file.close();
              
                Toast.makeText (getApplicationContext(), "Saved :", Toast.LENGTH_LONG).show ();
                System.out.println("Pdf created successfully..");

            } catch (Exception e) {
                e.printStackTrace();
            }


i hope its working fine.

how to download play store app to pc

 

Google play store apllications Direct dowmload to pc click below the link

Instructions :

Copy and paste google play store url

then click generate Download link

Direct link Click Here 

Untitled

how to Disable right click and copy paste in webpage

 

 

Very Simple Method and Easy Disable right click on webpage

Use java script in <head>  tag

Copy and paste the script

<SCRIPT LANGUAGE="JavaScript"> 
<!-- Disable 
function disableselect(e){ 
return false 

function reEnable(){ 
return true 

//if IE4+ 
document.onselectstart=new Function ("return false") 
document.oncontextmenu=new Function ("return false") 
//if NS6 
if (window.sidebar){ 
document.onmousedown=disableselect 
document.onclick=reEnable 

//--> 
</script>

I hope it working fine.

Use of Wrapper classes in java





Introduction

Java is an object-oriented language and can view everything as an object. A simple file can be treated as an object (with java.io.File), an address of a system can be seen as an object (with java.util.URL), an image can be treated as an object (with java.awt.Image) and a simple data type can be converted into an object (with wrapper classes). This tutorial discusses wrapper classes. Wrapper classes are used to convert any data type into an object.

 The primitive data types are not objects; they do not belong to any class; they are defined in the language itself. Sometimes, it is required to convert data types into objects in Java language. For example, upto JDK1.4, the data structures accept only objects to store. A data type is to be converted into an object and then added to a Stack or Vector etc. For this conversion, the designers introduced wrapper classes.



 What are Wrapper classes? 


 As the name says, a wrapper class wraps (encloses) around a data type and gives it an object appearance. Wherever, the data type is required as an object, this object can be used. Wrapper classes include methods to unwrap the object and give back the data type. It can be compared with a chocolate. The manufacturer wraps the chocolate with some foil or paper to prevent from pollution. The user takes the chocolate, removes and throws the wrapper and eats it.
 


Observe the following conversion.

int i = 10;
Integer it = new Integer(i);


The int data type i is converted into an object, it using Integer class. The it object can be used in Java programming wherever i is required an object.
The following code can be used to unwrap (getting back in from Integer object) the object it.

int m = it.intValue();
System.out.println(m*m);
// prints 100 -

intValue() is a method of Integer class that returns an int data type.
List of Wrapper classes

In the above code, Integer class is known as a wrapper class (because it wraps around int data type to give it an impression of object). To wrap (or to convert) each primitive data type, there comes a wrapper class. Eight wrapper classes exist in java.lang package that represent 8 data types. Following list gives.

  











Following is the hierarchy of the above classes. –










All the 8 wrapper classes are placed in java.lang package so that they are implicitly imported and made available to the programmer. As you can observe in the above hierarchy, the super class of all numeric wrapper classes is Number and the super class for Character and Boolean is Object. All the wrapper classes are defined as final and thus designers prevented them from inheritance.

Importance of Wrapper classes
There are mainly two uses with wrapper classes.
1.    To convert simple data types into objects, that is, to give object form to a data type; here constructors are used.
2.    To convert strings into data types (known as parsing operations), here methods of type parseXXX() are used.
The following program expresses the style of converting data type into an object and at the same time retrieving the data type from the object.