Showing posts with label Java Library. Show all posts
Showing posts with label Java Library. Show all posts

Friday, 9 August 2013

Mod2 Division

 Hi there, its been a while i have not posted any thing just busy with my strong & hectic college schedule, today i m posting one of my work called

MOD2 DIVISION.


There is a reason to code this small library which performs mod2 division :
And the reason is , when implementing CRC in software we need to perform mod2 division.

for those who don't know what is CRC?.

How to use this Library ?


Modulo2Div modulo2Div = new Modulo2Div();
modulo2Div.setDividend("1111101");
modulo2Div.setDivisor("10001");
modulo2Div.mod2Div();
System.out.println( "QUo = " + modulo2Div.getQue() + " Rem = " + modulo2Div.getRem());


Note: inorder to use this library you must set this mod2lib.jar in your classpath.

Download






Monday, 20 August 2012

IO-Utilities

Whenever I take any new project, I always require my Utilities library which provides me following features:

  1. Copying my library from dependency to  C Drive or  user's home directory in windows or *nix systems
  2. Compressing/Decompressing any Images or files for uploading or transferring it over network
  3. Getting extension of any file name in faster way
All this features can be achieved using just one library, and using this library is dam easy...even you can attach a listener to listen the processing i.e.
  • Name, count, size, compression level, copying from & copying to path of the file which library is processing ..

To attach a listener use this code



import fileutilslibrary.CopyEvent;
import fileutilslibrary.FileUtils;
import fileutilslibrary.Listener;
import fileutilslibrary.ZipEvent;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Naved Momin<naved.spartans.rocks75@gmail.com>
 */
public class Demo2 implements Listener{

    void start( ) throws IOException{
        FileUtils.getInstance().addListener(this);
     
        FileUtils.zipMyFolder(new File("C:\\Users\\Admin\\Desktop\\imgToVideo/RemoteDesktop"),
                  new File("C:/Users/Admin/Desktop/HMS Latest/RDnew.zip"),9);
                 

     
    }
    public static void main(String[] args) {
 
        try {
            // TODO code application logic here
            new Demo2().start();
        } catch (IOException ex) {
            Logger.getLogger(Demo2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void copyListener(CopyEvent e) {
        //notification about copying event
    }

    @Override
    public void zipListener(ZipEvent e) {
        //notification about zip event
        System.out.println( "name " +e.getZipingFileName() +  "\n" + "size " + e.getZipingFileSize() + "\n" +
        " count " + e.getFileCount( ) + "\n" +
        "level  " + e.getCompressionLevel() );
    }
}

Various Methods:-


Copy a Directory


FileUtils.copyDirectory(src, dest);

Copy a File


FileUtils.copyFile(src, dest);

Zip Directory 


FileUtils.zipMyFolder(src, dest);

Zip Directory With Custom Compression Level


FileUtils.zipMyFolder(src, dest, compressionLevel);

Note: Compression level must be between 0-9, by default 0 is used

Zip File


FileUtils.zipMyFile(src, dest);

Zip File With Custom Compression Level


FileUtils.zipMyFile(src, dest, compressionLevel);

Note: Compression level must be between 0-9, by default 0 is used

UnZip File


FileUtils.doUnZip(src, dest);

Get File Extension (10x faster)


FileUtils.getExtension(path);

Reverse a String


FileUtils.reverse(str);

Get File Name 


FileUtils.getName(pathToFile);


Note: The library is written in pure Java code except the Wallpaper class which throws NotSupportedOSException if OS is not supported by the library for more information see Javadoc included in the download package.
This library is totally compatible with various 3rd party zip utilities like winrar, which means you can zip your files programmatically and still use winrar for unzip'ing the file or vice-versa is also possible. 

For any bug or suggestions mail me at naved.spartans.rocks75@gmail.com

This Library is License under GNU General Public License

Download latest builds





Saturday, 11 August 2012

Programatically setting wallpaper


Last week when i was doing random visit at forums I found a Question 
How to Programatically set wallpaper in windows" so i have written a code to solve this problem of that guy..... 
Setting wallpaper in windows is never this easy, all you need is my API to set & get wallpaper, this library is part of my Utilities framework and written in Java. After you have set my library in your classpath (For those who don't know how to set classpath), all you have to do is follow the below instructions


Things you should know before using this API



In windows platform when we set any image as a wallpaper, windows actually copy the image into directory "C:\Users\[username]\AppData\Roaming\Microsoft\Windows\Themes" and name it as "TranscodedWallpaper". So when ever you set any wallpaper try browsing this directory and see the result. If you haven't understand this no problem!
Go ahead and try the API you will understand the working...

  • To set wallpaper in windows just use this code 
new Wallpaper().setWallpaper( Path );
  • To get current wallpaper's path use this code
new Wallpaper().getWallpaper();

Current version 1.0 is for Windows only.

Note: Always download latest builds.