First method to disaply cafebabe
give any class you will get the corresponding magic code
import java.io.*;
import java.util.*;
class Converter
{
public static void main(String ...args)
{
FileInputStream fis=null;
Scanner sc=null;
PrintWriter pw=null;
try
{
sc=new Scanner(System.in);
System.out.println("enter class file namefollowed by .class");
String s=sc.next();
fis=new FileInputStream(s);
pw=new PrintWriter(new FileOutputStream("ram.txt"));
int k;
while((k=fis.read())!=-1)
{
if(k==10)
pw.println();
pw.write(Integer.toHexString(k));
}
}
catch(Exception e)
{
}
pw.flush();
}
}
import java.util.*;
class Converter
{
public static void main(String ...args)
{
FileInputStream fis=null;
Scanner sc=null;
PrintWriter pw=null;
try
{
sc=new Scanner(System.in);
System.out.println("enter class file namefollowed by .class");
String s=sc.next();
fis=new FileInputStream(s);
pw=new PrintWriter(new FileOutputStream("ram.txt"));
int k;
while((k=fis.read())!=-1)
{
if(k==10)
pw.println();
pw.write(Integer.toHexString(k));
}
}
catch(Exception e)
{
}
pw.flush();
}
}
Second Method:
Using debug command in windows
debug command is there in c:\windows\system32
check once wheather you system having it or not
if it is not there then download it
debug has two basic options
d-display
q-quit
when ever we enter command an - symbol come which indicates that debug command is there in your system
for
unix system
use
grep command
ex: grep -d test.class
Third way
edit plus 3.0 have feature of displaying the code in hex decimal form
so
first open the class file with edit plus 3.0
and then select
hexa decimal view