Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
22.8k 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 (162k points)
Perhaps the server is configured to not permit overwrites, or your userid may not have write permission.

Another possibility is a store unique flag that forces the file to be saved as another name - are there new files appearing?
0 votes
by (260 points)
Perhaps the server is configured to not permit overwrites, or your userid may not have write permission.

Another possibility is a store unique flag that forces the file to be saved as another name - are there new files appearing?



I enabled all logging and showed it to our mainframe guy - he said I have to put single or double quotes around my filename. The problem is that when I try to do what he suggested the ftp fails. Any thoughts?
0 votes
by (162k points)
What do you mean by it fails? Can you post a snippet of the logfile?
0 votes
by (260 points)
What do you mean by it fails? Can you post a snippet of the logfile?



It doesn't ftp when I add single quotes around the file name as our Mainframe guy suggested. When enable logging I get an FileNotFoundException.


DEBUG [FTPClient] 14 Mar 2008 08:24:26.446 : Connecting to /XXX.XXX.XXX.XXX:XX
DEBUG [SocketUtils] 14 Mar 2008 08:24:26.446 : Invoking connect with timeout=60000
DEBUG [SocketUtils] 14 Mar 2008 08:24:26.446 : Connected successfully
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.446 : 220-FTPD1 IBM FTP CS V1R7 at XXX, 13:24:57 on 2008-03-14.
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.618 : 220 Connection will close if idle for more than 5 minutes.
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.618 : ---> USER XXXXX
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.618 : 331 Send password please.
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.618 : ---> PASS ********
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.790 : 230 XXXXX is logged on. Working directory is "XXXXX.".
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.790 : ---> TYPE A
DEBUG [FTPControlSocket] 14 Mar 2008 08:24:26.790 : 200 Representation type is Ascii NonPrint
java.io.FileNotFoundException: 'FILE.NAME' (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:129)
at java.io.FileInputStream.<init>(FileInputStream.java:89)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2020)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1999)
at DebtCollectQuickFix.sendFile1(DebtCollectQuickFix.java:457)
at DebtCollectQuickFix.main(DebtCollectQuickFix.java:38)
0 votes
by (162k points)
You need quotes around the *remote* filename. Java can't find the local file with quotes around it.
0 votes
by (260 points)
You need quotes around the *remote* filename. Java can't find the local file with quotes around it.


Should known that - it works! Thanks!

:roll:
0 votes
by (340 points)
I have the same problem, i was making a class in java in where i use the edtFTPj, and i conect to a mainframe z/OS, but i still have a dude, when i do a get/put method, how i need write it in my class?

i have the next line code in my class

for get:
client.get(objectFile.getName()); (where client is a FTPClient object, and object file is my file name)

for put:
client.put(str_fileName, str_name, false); (same case client is FTPClient object, str_fileName is my file name on mainframe, str_name is the new file which i will upload to a mainframe)

i need make some as this:

for get:
client.get("'" + objectFile.getName() + "'");

for put:
client.put(str_fileName, "'" + str_name + "'", false);

??
0 votes
by (51.6k points)
Firstly, get(String) returns a byte-array instead of saving the file locally. You need to use get(String,String), which does save the file locally using the given name.

Secondly, you don't need to put quotes around the file-name at all.

- Hans Andersen (EnterpriseDT)
0 votes
by (340 points)
sorry, yea for the first :S sorry,

i really want to get the array, i wanna get the content from the file. the problem is that i make test on windows and i get the content, but my surprise was when i see that my test is not correct because the real FTP is not on windows is on z/OS. Then I wanna get the all Content from the file.

and for the second, Then i no need use this "'"?

this is part of my code,

try
      {
         FTPFile[] dirlist;
         dirlist = client.dirDetails(".");
         
         for (int i=0; i<dirlist.length; i++) 
         {
            FTPFile objectFile = dirlist[i];
            
            
            if (objectFile.isLink()) 
            {
               //Ignorarlo.
            }
            else if (objectFile.isDir()) 
            {
               //En caso de usar recursividad
            }   
            else
            {
               if (validaDocumento(objectFile.getName(), str_NomFileFilter))
               {
                  
                  byte[] content;
               
                  
                  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.6k points)
Can you please set the logging level to DEBUG and post the relevant part of the log? Hopefully we'll see an error-message that will tell us what the problem is.

- Hans (EnterpriseDT)

Categories

...