Solved

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

Posted on 2003-10-31
6
355 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

829 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