Solved

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

Posted on 2003-10-31
6
349 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
thymeleaf natural templating vs JSP 2 68
simple java question 3 44
Java Timer (static) 9 36
Windows 10 IE Certificate Issue 10 42
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

895 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

13 Experts available now in Live!

Get 1:1 Help Now