Friday, 13 June 2014

Why We Use Web Services?


Ø AS Web Services are some Piece of code, there is chance of exposing the functionality of a service over a network. By this Other Applications can Use these Functionalities.

Ø By using Web Services different types of Applications can communicate each other.


Ø It Uses Wide variety of Protocol stack so that  there is somany advantages like wide range of choices and reduction in Cost.

Ø It uses simple and cost Effective protocols like SOAP,HTTP etc.


Ø Besides these also uses many protocols if necessary.

Ø Use variety of technologies to implement web services and these are self explanatory.


Ø It automatically discovers the service providers near by it and starts communicate.

Ø New services can easy to Enter and starts their business.


Web services are mixture of HTTP, XML that convert it to web applications and share these to rest of the World.
It consists of elements like Http, SOAP, WSDL.

Thursday, 12 June 2014

How to upload a file in blogger for download?

Upload a file and direct Download from blog

  When you need to Upload a small file into Web and share with your followers without leaving them from your blog to another hosting file for Download a file.How can i ?Read the Scenario , A Adobe Photoshop Designer Needs to Share his source file(PSD file format) of his Image to his Followers of his Blog.He don't need to Leave them his Blog into Hosting Site that contains malicious ads.


   Go to       https://sites.google.com    and Create a New site.

    
   Now Create a page in File Cabinet.
  

    






After Click on "Add File" and Browse the File and Upload it.
After Uploading the Image , Right Click on "Download" and select "Copy the Link Address"


Go Back to Blogger Post and Tyep "Download File "and Make Link into copied Link address.



    How to zip a file with password using java?



    You can do this one by using the

    sevenzipjbinding.jar and winzipaes-
    20100321.jar

    You can down load the jars by clicking the below link






    You can copy the Code and  Execute the code Directly by Adding the Jars to Classpath

    Service Class:

     import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import de.idyl.crypto.zip.AesZipFileEncrypter;

    public class ZipUtil {

    public static void zipDirWithPassword( String dirName , String zipFileName , String password)
    {
    if( zipFileName == null )
    {
    File tempFile = new File(dirName);
    zipFileName = tempFile.getAbsoluteFile().getParent() +File.separator+tempFile.getName()+".zip";
    }
    zipDir(dirName, zipFileName);
    String tempZipFileName = new File( dirName ).getAbsoluteFile() .getParent()+File.separator+"tempencrypted.zip";
    try
    {
    AesZipFileEncrypter enc = new AesZipFileEncrypter (tempZipFileName);
    enc.addEncrypted( new File(zipFileName), password);
    new File(zipFileName).delete();
    new File( tempZipFileName ).renameTo( new File (zipFileName));
    }
    catch (IOException e) 
    {
    e.printStackTrace();
    }
    }//method ZipWith Password
    public static void zipDir( String dirName , String zipFileName )
    {
    if( zipFileName == null )
    {
    File tempFile = new File(dirName);
    zipFileName = tempFile.getAbsoluteFile().getParent()+ File.separator+tempFile.getName()+".zip";
    }
    try 
    {
    ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFileName));
    compressDir(dirName, zos, new File(dirName).getName()+File.separator);
    zos.close();
    }
    catch( NullPointerException npe )
    {
    npe.printStackTrace();
    }
    catch (FileNotFoundException e)
    {
    e.printStackTrace();
    }
    catch( IOException ie )
    {
    ie.printStackTrace();
    }
    }//Method zipDir
    private static void compressDir(String directory, ZipOutputStream zos, String path) throws IOException {
    File zipDir = new File(directory);
    String[] dirList = zipDir.list();
    byte[] readBuffer = new byte[2156];
    int bytesIn = 0;
    for (int i = 0; i < dirList.length; i++) 
    {
    File f = new File(zipDir, dirList[i]);
    if (f.isDirectory()) 
    {
    String filePath = f.getPath();
    compressDir(filePath, zos, path + f.getName() + "/");
    continue;
    }
    FileInputStream fis = new FileInputStream(f);
    try 
    {
    ZipEntry anEntry = new ZipEntry(path + f.getName());
    zos.putNextEntry(anEntry);
    bytesIn = fis.read(readBuffer);
    while (bytesIn != -1)
    {
    zos.write(readBuffer, 0, bytesIn);
    bytesIn = fis.read(readBuffer);
    }
    }
    catch( Exception e )
    {
    e.printStackTrace();
    }
    finally 
    {
    fis.close();
    }
    }
    }// Method CompressDir


    }//Class



    Main Class:



    public class MainClass 
    {


    public static void main(String[] args)
    {
    ZipUtil.zipDirWithPassword("F:/ZipaFolderUsingPassword/ZipaDirectoryUsingPassword/inputFiles","F:/ZipaFolderUsingPassword/ZipaDirectoryUsingPassword/ZipFolder/zipfile.zip", "abcd1234");



    }//main method

    }//class