Archive for the 'Java' Category

Given code can help you to compute checksum.
/* pseudo header for checksum calculation */ typedef struct pseudoh {     guint32 src_addr;     guint32 dest_addr;     guint8  zero;     guint8  protocol;     guint16 [...]


Please visit: http://aimslife.com/blog/?p=9


package com.Web;
import java.io.*;import java.net.*;
public class WebServer extends Thread {    String filePath;    OutputStream out;    Socket sock;    public WebServer(String pathString, OutputStream outStream, Socket s) {        filePath = pathString;        sock = s;        out = outStream;    }    public void run() {        PrintWriter writer = new PrintWriter(out, true);        try {            filePath = (new [...]


Person A: Do you know??Person B: about what??Person A: From where I can contribute and learn .Net, Java, etc compiler….???Person B: … <difficult question…> … Person A: answer is so simple… go on http://discuss.develop.com/ and join Rotor group, GenX group, Java-Security group, .Net-CLR group and many other informative information are there.
Best Of lUck!.


How we can get size of Object in Java?
Bellow code will give you size of Object in java.
public static byte[] sizeOf(Object obj) throws java.io.IOException
{
ByteArrayOutputStream byteObject = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteObject);
objectOutputStream.writeObject(obj);
objectOutputStream.flush();
objectOutputStream.close();
byteObject.close();
return byteObject.toByteArray();
}


How we can get pid of own application?
Below code will give you some important information, which can be helpful for you.
    public static void main(String[] args)    {        System.out.println(ManagementFactory.getRuntimeMXBean().getName());        System.out.println(ManagementFactory.getRuntimeMXBean().getBootClassPath());        System.out.println(ManagementFactory.getRuntimeMXBean().getClassPath());        System.out.println(ManagementFactory.getRuntimeMXBean().getLibraryPath());        System.out.println(ManagementFactory.getRuntimeMXBean().getManagementSpecVersion());        System.out.println(ManagementFactory.getRuntimeMXBean().getSpecName());        System.out.println(ManagementFactory.getRuntimeMXBean().getSpecVendor());    }
But
System.out.println(ManagementFactory.getRuntimeMXBean().getName());
It will give you own application pid.