Solved

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

Posted on 2003-10-31
6
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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…
Suggested Courses

739 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