Solved

Sitecommand in org.apache.commons.ftp against a mainframe - has file already been uploaded

Posted on 2003-10-31
6
347 Views
Last Modified: 2012-06-27
I have this

            try {
                  siteCommand = "LRECL=" + lrecl;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  siteCommand = "BLOCKSIZE=" + blksize;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  siteCommand = "RECFM=" + recfm;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  siteCommand = "VOLUME=" + theVolume;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  siteCommand = spaceType;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  siteCommand = "PRIMARY=" + primarySpace;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  siteCommand = "SECONDARY=" + secondarySpace;
                  ftpReply = ftp.site(siteCommand);
                  showMsg(ftp.getReplyString() + ": " + siteCommand, verbose);
                  // No port command necessary
                  FileInputStream local = new FileInputStream(fileName);
                  if (ftp.storeFile(mvsFileName, local)) {
                        showMsg("Stored Ok:" + ftp.getReplyString(), true);
                  }
                  else
                        showMsg("Problems storing:" + ftp.getReplyString(), verbose);
                  local.close();
                  return true;
            }
Any way I can figure out before I do the stor if the file already exists or do I have to do an LS or such
And if so, how do I do that and get the data into an form where I can test the existence of the file???
Thanks

Michel

0
Comment
Question by:Michel Plungjan
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9657877
It certainly will need some kind of listing. Look at FTPFileList
0
 
LVL 75

Author Comment

by:Michel Plungjan
ID: 9658485
Any chance of finding me an example?
The apache javadoc is as terse as anything I have read...

Thanks
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 9658610
None that I can find. I can give you a couple of tips from looking at the docs:

1. use FTPClient not FTP, if you're not already doing that
2. call createFileList on the FTPClient, using your own FTPFileEntryParser with an implementation that closes the stream if the entry is found and returns a FTPFileList of one element, null otherwise
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 75

Author Comment

by:Michel Plungjan
ID: 9659150
Why would I not use ftp???
0
 
LVL 75

Author Comment

by:Michel Plungjan
ID: 9659152
thanks by the way
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9665981
>>Why would I not use ftp???

Because it's a superclass of FTPClient with reduced functionality (at a fairly quick glance)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wordcount challenge 11 76
HashMap Vs TreeMap 12 49
Running Jira on Raspberry PI 2? 3 127
JDeveloper 12c for 32 bit 4 34
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now