MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.security.MessageDigest;

public class MainClass {
    public static void main(String args[]) throws Exception {
        FileOutputStream fos = new FileOutputStream("test");
        MessageDigest md = MessageDigest.getInstance("SHA");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        String data = "thee";
        byte buf[] = data.getBytes();
        md.update(buf);
        oos.writeObject(data);
        oos.writeObject(md.digest());
    }
}