Moving/Renaming a File in PeopleCode using Java

It’s been a while since I posted. Here’s a code snippet that allows you to move/rename the file from one directory to another directory using Java functions in PeopleCode. These commands work on both NT and Unix servers.


Local JavaObject &source = CreateJavaObject("java.io.File", &SourceDirectoryWithFileName);
Local JavaObject &target = CreateJavaObject("java.io.File", &TargetDirectoryWithFileName);
&source.renameTo(&target);

Hope this helps! 🙂

Advertisements

About Manikandan Surendren

A PeopleSoft Techno-functional Consultant. An engineering graduate in Computer Science. Technology Enthusiast. Movie freak. Gadget geek.
This entry was posted in Code, PeopleSoft and tagged , , , . Bookmark the permalink.

2 Responses to Moving/Renaming a File in PeopleCode using Java

  1. Chris M says:

    When I try that piece of code in my AE program, I am passing in a variable with the source/target location and it does not archive the file.

    &input = &path;
    &output = &archivePath | &FN;

    Local JavaObject &source = CreateJavaObject(“java.io.File”, &input);
    Local JavaObject &target = CreateJavaObject(“java.io.File”, &output);

    &source.renameTo(&target);

    &path, &archivePath and &FN are variables with strings attached. It only allows me to archive the file when the input/output variables are hardcode with a string.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s