java's dir question.

Hi all,

I have a java service that is basically scanning a directory. To be short, the code looks like :

String dir_list[];
dir_list = dir.list();
idcPipeline.insertAfter("fileList", dir_list);

Then this service is used in a web service.

The problem is “fileList” parameter is not an array of string as expected but an array of pointer (according to the pipeline’s icon for this field) so the consumer of my webService can’t read it :

object(stdClass)#5 (1) {
  string(27) "[Ljava.lang.Object;@9113f94"

As consequence, I have to loop against this array in a Flow in order to
build a real string array. Any way more efficient way to do that ? How
can I get directly an array of string as output of my java service ?



I’ve tried this code in a java service

And when i run it, the fileList is a String List
can you try ?

I’v tested on IS 6.5.

Thanks arnaud.

It is :confused:

The full code is :

IDataCursor idcPipeline = pipeline.getCursor();

String filterString = null;
if (idcPipeline.first("filter")) {
  filterString = (String) idcPipeline.getValue();

String directory = null;
if (idcPipeline.first("directory")){
  directory = (String) idcPipeline.getValue();
} else {
  throw new ServiceException("Directory is null!");

String MaxNum = null;
if (idcPipeline.first("MaxFiles")) {
  MaxNum = (String) idcPipeline.getValue();

Integer FromDate = null;
if (idcPipeline.first("FromDate")) {
   FromDate = Integer.valueOf((String) idcPipeline.getValue()).intValue();
Integer ToDate = null;
if (idcPipeline.first("ToDate")) {
    ToDate = Integer.valueOf((String) idcPipeline.getValue()).intValue();

File dir = new File(directory);
if (!dir.exists() || !dir.isDirectory()) {
  throw new ServiceException("Error reading inbox directory!");

String dir_list[];
if ((filterString != null) && filterString.length() > 0){
  JZOOWildCardFilter filter = new JZOOWildCardFilter(filterString);
  dir_list = dir.list(filter);
} else {
  dir_list = dir.list();

Arrays.sort(dir_list, Collections.reverseOrder());

if(FromDate != null){
[B]    Vector lst = new Vector();
    int i;[/b]

[B]    for(i=0; i<dir_list.length; i++){
        Integer j = Integer.valueOf(dir_list[i].substring(0,8)).intValue();
        if(j >= FromDate && j <= ToDate)
    Object res[] = lst.toArray();
    idcPipeline.insertAfter("fileList", res);
} else if(MaxNum != null){
    int i = Integer.valueOf(MaxNum).intValue();
    if ( i != 0 && i <  dir_list.length){
        String ndl[] = new String[ i ];
        System.arraycopy(dir_list,0, ndl, 0, i);
        idcPipeline.insertAfter("fileList", ndl);
idcPipeline.insertAfter("fileList", dir_list);

In my case, MaxFiles is empty and I use FromDate and ToDate … I suspect the “Vector” manipulation to convert to pointer :angry: I’m not a java expert so it was the most logical way I found to do that.

Any better way ?




and it should work :happy:

it’s an object not a pointer :wink:

Working very well :smiley:

Thanks a lot.