java - FTP文件到主机

标签 java ftp mainframe

我正在尝试通过 FTP 将 JCL txt 文件传输到大型机:

// Connect to the server
        ftp.connect(host);
        replyText = ftp.getReplyString();
        System.out.println(replyText);

        // Log into the server
        ftp.login(userId, password);
        replyText = ftp.getReplyString();
        System.out.println(replyText);


        // Tell the server to use the JES interface
        ftp.sendSiteCommand("FILETYPE=JES");
        replyText = ftp.getReplyString();
        System.out.println(replyText);

        //read JCL file in input stream
        FileInputStream fileStream = new FileInputStream(file);

        String originalFileName = "ca7jcl.txt";

        ftp.setFileType(FTP.ASCII_FILE_TYPE);

        //store the JCL file
        ftp.storeFile(host, fileStream);
        replyText = ftp.getReplyString();
        System.out.println(replyText);

但得到 250-JES 将其称为 *UNKNOWN 我该如何解决这个问题?

最佳答案

我假设您想在 FTP 时运行 JCL 文本文件。

附上 try {}catch {} block (如果没有完成)。

这是代码(这对我有用):

// FTPClient ftp = new FTPClient(); Assumed in your code
//Connect to the server 
try
{
    ftp.connect(host);
    replyText = ftp.getReplyString();
    System.out.println(replyText);
} catch (Exception  e)  { e.printStackTrace () ; }

//Login to the server 
try 
{ 
    ftp.login(userId, password);
    replyText = ftp.getReplyString();
    System.out.println(replyText);
} catch (Exception e) { e.printStackTrace(); } 

// Tell the server to use the JES interface
try
{ 
    // Instead of sendSiteCommand()
    // ftp.sendSiteCommand("FILETYPE=JES");

    // Try site() with everythng in lowercase
    ftp.site ("filetype=jes") ; 
    String replyText = ftp.getReplyString() ; 
    System.out.println (replyText) ; 
} catch (Exception e) { e.printStackTrace(); } 

//Submit the job from the text file.Use \\ to avoid using escape notation 
try 
{ 
    //read JCL file in input stream
    //String originalFileName = "ca7jcl.txt";

    String path = "" //Store your file's absolute path here 
    FileInputStream fileStream = new FileInputStream(path);

    //store the JCL file
    ftp.storeFile(host, fileStream);
    replyText = ftp.getReplyString();
    System.out.println(replyText);
 }  catch (Exception e) { e.printStackTrace(); } 

让我们知道这是否有帮助。 :)

关于java - FTP文件到主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28106752/

相关文章:

python - 如何使用 python 创建 csv 文件直接到 ftp 服务器?

linux - 来自 Linux 的远程大型机 session

cobol - 编写从单独的 vsam 文件中提取信息的 Cobol 程序时遇到问题

java - 403 Forbidden - 在 Weblogic 中部署 Spring Boot 应用程序

java - MyEclipse - 将 war 文件部署到 tomcat

java - 如何在 Spring Boot 应用程序中缓存复杂对象,例如 Map<String, List<Car>>

java - 如何更改匿名类中的实例变量

LINUX:如何检测ftp文件上传完成

java - 在 Java 中获取 FTP 文件的 MD5 校验和

linux - sftp 中 ftp 的 SITE 命令有什么替代方法