Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
22.4k views
in Java FTP by (260 points)
Usually when I ftp a file to a Windows or Unix server where the file already exists the file on the server is overwritten. This was not the case when I ftp-ed a flat text file to a Mainframe - my file did not overwrite the one on the Mainframe. Is there a special step involved? Could it be a EBCIDIC vs ASCII thing?

17 Answers

0 votes
by (340 points)
this is only for the get event, my code since start the event
try
      {
         FTPFile[] dirlist;
         dirlist = client.dirDetails(".");
         System.out.println("dir list: " + dirlist.length);
         for (int i=0; i<dirlist.length; i++) 
         {
            FTPFile objectFile = dirlist[i];
            
            System.out.println("objectFile getName: " + objectFile.getName());
            if (objectFile.isLink()) 
            {
               //Ignorarlo.
            }
            else if (objectFile.isDir()) 
            {
               //En caso de usar recursividad
            }   
            else
            {
               if (validaDocumento(objectFile.getName(), str_NomFileFilter))
               {
                  System.out.println("ValidaDocumento: true");
                  byte[] content;
               
                  System.out.println(objectFile.getName());
                  client.setType(m_type);
                  content = client.get(objectFile.getName());
                  m_contenido = content;
                        
                  //Agrega un sufijo al nombre del archivo sin considerar la extension
                  String[] arr = objectFile.getName().split("\\.");               

                  if(arr.length < 2)
                  {
                     nombreArchivo = objectFile.getName();
                  }
                  else
                  {
                     int k = 0;
                     for(k = 0 ; k < arr.length ; k++ )
                     {
                        //Si trae nombre de archivo.extension la agrega el sufijo al nombre de archivo
                        if (k == arr.length -2 )
                        {
                           nombreArchivo += arr[k] + sufijo + "." ;
                        }
                        else if (k == arr.length -1 )
                        {
                           nombreArchivo += arr[k];
                        }
                        else
                        {
                           nombreArchivo += arr[k] + ".";
                        }
                     }     
                  }
                  
                  // Recupera el contenido del archivo
                  File filelocal = new File(m_dirDestino + nombreArchivo);
                  filelocal.createNewFile();
                  FileOutputStream out = new FileOutputStream(m_dirDestino + nombreArchivo);
                  out.write(content);
                  out.flush();
                  out.close();
                  NomArchivos.add(nombreArchivo);
                  
                  //Si se indica que se elimine se elimina del ftp
                  if(elimina == 1)
                  {
                     client.delete(objectFile.getName());
                  }
               }
            }
         }
      }
0 votes
by (51.1k points)
Please post a log. Instructions for generating a log may be found here.

- Hans (EnterpriseDT)
0 votes
by (340 points)
hey people, thnx for ur time, i only say my program now is ok :D, the problem was that when i did the get method i was using an function for find directory, but my problem was there, cuz my problem never found it. now, it is ok :). my first problem was here: http://www.enterprisedt.com/forums/viewtopic.php?t=3020 but now it is ok, thnx people for help me
0 votes
by (340 points)
aaaaaa sorry for my english :(
0 votes
by (51.1k points)
Your English is fine. Thanks for letting us know how to get it working.

- Hans (EnterpriseDT)
0 votes
by (140 points)
Hey all,

For a recent customer, we needed to implement an MVS z/OS parser implementation that I'd like to contribute back. Additionally, I've found a few things out about the z/OS mainframe FTP that I'd like to share for people stumbling around with this:

a- Neither SIZE nor MDTM are supported by MVS z/OS.

b- Using LIST with a dot as an argument for the current directory (like in linux "LIST .") doesn't work at all on the mainframe.

c- Because of (a) and (b) above, the current code in FTPClient for the exists() method doesn't work. I've had to subclass FTPClient, and copy/paste the contents of the exists to make a single change. From dirDetails(".") to dirDetails(null) which works fine.

d- While it's true that adding a parser is possible (thank goodness), the current design doesn't easily lend itself to extensibility.

1- The only way to add a new parser in is to instance the FTPFileFactory yourself - fair enough, but your only constructor requires the system type so it can pick a parser. But you're trying to give it a new parser - it's a chicken-and-egg. And you'll always give the message that the system type is unrecognized and it's going to fall back to the UNIX parser, but then it will choose your specific parser thanks to the other logic.

2- Unfortunately, the setParser method in the FTPFileFactory is private, and hardcoded for just the auto-detection of the known ones. Then, after it decides to fall-back to UNIX format, it will still pass the rows around to see who could parse it. It would be better organized in my opinion if you could instance a FTPFileFactory, give it all the extra possible parsers, and either have the recognition done based on the declared system, or not use the system at all (just the format validation).

I'd love to contribute the MVSFileParser - how do you accept contributions?

Marc Batchelor
Pentaho Corporation
http://www.pentaho.com

[edited for spelling]
0 votes
by (161k points)
Thanks very much Marc - we've sent you an email.

Categories

...