java service for getting the modified timestamp of all the files in a directory.

Hi All!. I have a problem, I want to get the modified date of all the files in a directory. can anyone tell what is wrong with it? Here is my java service:

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String directory = IDataUtil.getString( pipelineCursor, “directory” );
pipelineCursor.destroy();
File folder = new File(“c:/”);
File listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
long datetime=listOfFiles[i].lastModified();
Date date=new Date(datetime);
MDList=date;
}
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
String MDList = new String[1];
MDList[0] = “date”;
IDataUtil.put( pipelineCursor_1, “MDList”, MDList );
pipelineCursor_1.destroy();

directory is input and MDList is the output.

:sad:

hey ankit,

I believe this is the solution for your query.

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String directory = IDataUtil.getString( pipelineCursor, “directory” );
pipelineCursor.destroy();
File folder = new File(directory);
File listOfFiles = folder.listFiles();
String MDList=new String
[listOfFiles.length]
;
for (int i = 0; i < listOfFiles.length; i++) {
long datetime=listOfFiles[i].lastModified();
Date date=new Date(datetime);
MDList[i]=date.toString();
}
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “MDList”, MDList );
pipelineCursor_1.destroy();

Please do not forgot to import java.io.,java.util. in the shared tab.

Thanks ,
Amol.

Thanks amol.
This is working.