|
-
Jul 30th, 2002, 04:28 AM
#1
Thread Starter
Lively Member
one simple question
hi friends,
there is one problem.in java there are source file and there objects are made when we compile it.now i want to compare the date of source file and the object and find out which one is later modified.
plz help me i am a beginner
my code is:
import java.io.*;
import java.util.*;
public class MileStone1
{
public static void main(String args[])
{
System.out.println("<html><head></head><body><table width=100%>");
MileStone1 m1=new MileStone1();
m1.getDir(args[0]);
System.out.println("</table></body></html>");
}
public Vector getJava(String path)
{
Vector javaFile=new Vector();
try{
file f = new File(path);
String dirList[] = f.list();
for (int i = 0; i < dirList.length; i++) {
if(dirList[i].indexOf("java") != -1)
{
System.out.println("<tr>");
javaFile.addElement(dirList[i]);
Vector objs=getObjects(dirList[i],path);
System.out.println("<td width=25%>"+dirList[i]+"</td>");
System.out.println("<td width=25%>"+path+"</td>");
String classes_name="";
for(int k=0;k < objs.size(); k++)
{
// System.out.println(objs.elementAt(k));
classes_name = classes_name + objs.elementAt(k) +"\r\n";
}
System.out.println("<td width=25%>"+classes_name+"</td>");
System.out.println("<td width=25%>"+path+"</td>");
System.out.println("</tr>");
}
}
}catch(Exception ex){System.out.println("Get Java"+ex);}
return javaFile;
}
public Vector getObjects(String sourceName,String path)
{
Vector objects=new Vector();
sourceName =sourceName.substring(0,sourceName.indexOf("."));
try{
File f = new File(path);
String dirList[] = f.list();
for (int i = 0; i < dirList.length; i++) {
// System.out.println("ssss"+sourceName+".class") ;
if((dirList[i].indexOf(sourceName+".class") != -1))
{
// System.out.println("in adding class"+dirList[i]) ;
objects.addElement(dirList[i]);
}
else
{
if((dirList[i].indexOf(sourceName) != -1) && (dirList[i].indexOf("java") == -1) && (dirList[i].indexOf("$") != -1))
{
// System.out.println("in adding class1"+dirList[i]) ;
objects.addElement(dirList[i]);
}
}
}
}catch(Exception ex){System.out.println("Get Objects"+ex);}
return objects;
}
public void getDir(String baseFile)
{
try{
FileInputStream fis=new FileInputStream(baseFile);
DataInputStream dis=new DataInputStream(fis);
String dir=" ";
while(dir != null)
{
dir =(String) dis.readLine();
getDocument(dir);
}
}catch(Exception ex){System.out.println("Get Dir"+ex);}
}
public void getDocument(String path)
{
Vector javaFile= getJava(path);
}
}
regards
ishikha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|