FTPing a file to Mainframe using Java, Apache Common Net

Posted by SKR on Stack Overflow See other posts from Stack Overflow or by SKR
Published on 2010-12-31T11:24:40Z Indexed on 2010/12/31 12:53 UTC
Read the original article Hit count: 290

Filed under:
|
|
|
|

I'm am trying to upload a file into mainframe server using FTP. My code is below

FTPClient client = new FTPClient();  
InputStream in = null;  
FileInputStream fis = null;  
  try{  
               client.connect("10.10.23.23");  
               client.login("user1", "pass123");  
               client.setFileType(FTPClient.BINARY_FILE_TYPE);  
               int reply ;  
               reply = client.getReplyCode();  

      System.out.println("Reply Code:"+reply);  

      if(FTPReply.isPositiveCompletion(reply)){  

        System.out.println("Positive reply");  
        String filename ="D:\\FILE.txt";  

        in = new FileInputStream(filename);  
            client.storeFile("FILE.TXT", in);  
            client.logout();  
            fis.close();  

      }else{  
        System.out.println("Negative reply");  
      }

  }catch(final Throwable t){  
        t.printStackTrace();  
  }

The code gets struck in client.storeFile("FILE.TXT", in); I am unable to debug. Please suggest ways / solutions.

© Stack Overflow or respective owner

Related posts about java

Related posts about file