Question

5
Replies
3991
Views
saravanan kvkandasamy (saravanank1808)
Citigroup technology inc

Citigroup technology inc
US
saravanank1808 Member since 2015 22 posts
Citigroup technology inc
Posted: September 24, 2016
Last activity: January 1, 2017
Posted: 24 Sep 2016 19:27 EDT
Last activity: 1 Jan 2017 9:40 EST
Closed

Compiling java code in activity step

Below is the sample code which i am writing to retrieve the filename inside folder and subfolder by giving the directory name as an inputs

I am trying to use a user function/method to call the method if the file is a directory. But i am getting the following compilation error. I wanted to know what i am doing incorrectly.

Compilation Error

 

Test compilation failed: ----------
1. ERROR in /Rule_Obj_Activity_Citi_GCNA_RUSA_FileDownload_getDirectoryContents_Action_20160922T172011_508_GMT.java (at line 388)
public void listFilesAndFilesSubDirectories(String Path);{
^
Syntax error on token "(", ; expected
----------
2. ERROR in /Rule_Obj_Activity_Citi_GCNA_RUSA_FileDownload_getDirectoryContents_Action_20160922T172011_508_GMT.java (at line 388)
public void listFilesAndFilesSubDirectories(String Path);{
^
Syntax error on token ")", delete this token
----------
2 problems (2 errors)
Compile failed.

 

Java Code:

 

String files;    
String size;
public listFilesAndFilesSubDirectories(String Path){
java.io.File directory = new java.io.File(Path);
java.io.File[] fList = directory.listFiles(); 
tools.findPage("TempDirectoryListPage").getProperty(".FileLocation").setValue(Path); 

if(folder == null)
{
    tools.findPage("TempDirectoryListPage").getProperty(".DownLoadError").setValue("Either directory does not exist or is not a directory or No Access."); 

else
{
  ClipboardPage cp = tools.findPage("TempDirectoryListPage");
  ClipboardProperty CPProp=cp.getProperty("FileNamePageList");

  
    for (int i = 0; i < fList.length; i++) 
  {
    if (fList[i].isFile()) 
    {
          files = fList[i].getName();
          size =  String.valueOf(fList[i].length());
         ClipboardPage CPlist=CPProp.getPageValue(i+1);
    CPlist.putString("FileName",files );
    CPlist.putString("FileSize",size);
    }
    if (fList[i].isDirectory()) 
    {
      Path=new listFilesAndFilesSubDirectories(file.getAbsolutePath());
      files = fList[i].getName();
      tools.findPage("TempDirectoryListPage").getProperty(".DirectoryNameList(<APPEND>)").setValue(files);
         size =  String.valueOf(fList[i].length());
         ClipboardPage CPlist=CPProp.getPageValue(i+1);
    CPlist.putString("FileName",files );
    CPlist.putString("FileSize",size);

    }
  }
  }
  tools.findPage("TempDirectoryListPage").getProperty(".DownLoadError").setValue("Successfully retrieved the list of files from the above directory selected.");
}

 

***Updated by Moderator: Vidyaranjan. Removed user added Ask the Expert tag. Apologies for confusion, shouldn't have been an end-user option***

Low-Code App Development Data Integration Java and Activities
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.