1

我在我的 Ant 脚本中使用 javascript 将运行时网络远程文件夹值作为输入传递。传递该值后,我发现输入文件夹路径是否存在。但我无法做到这一点。我的代码如下。

    <script language="javascript">
    <![CDATA[
        importPackage(javax.io);
        importPackage(javax.swing);
        importPackage(java.lang);
        var deployment_machine = project.getProperty("var2");
        var deployment_machine = deployment_machine.substring(2,deployment_machine.indexOf("$")-2);
        var optionPane = JOptionPane.showInputDialog( 'Deployment location for GatewayFW in ' + deployment_machine + '?', null );
        var path = require('optionPane');
        if (path.existsSync("/the/path")) {
                // ...
            }

        if(!fso.FolderExists(optionPane))
        {
        var optionPane = JOptionPane.showInputDialog( 'Deployment location for GatewayFW in ?', deployment_machine );
        }
        else
        {
        project.setProperty('deploy_loc',optionPane);
        }           
    ]]>
    </script>
</then>
<else>
    <echo message="File need to check:- ${patch.path}/${patch.name}/GatewayFW_patch.zip is not exist"/>
</else>

`

任何人都可以帮我吗?

4

1 回答 1

1

<script language="javascript"> <![CDATA[ importPackage(java.io); importPackage(javax.swing); importPackage(java.lang); var deployment_machine = project.getProperty("var2"); var deployment_machine = deployment_machine.substring(2,deployment_machine.indexOf("$")-2);
do { var optionPane = JOptionPane.showInputDialog( 'Deployment location for GatewayFW in ' + deployment_machine + '?', null );
var dir = new File(optionPane); } while(!dir.exists()); project.setProperty('deploy_loc',optionPane); ]]> </script>
在这里,我们必须将 File("folder path") 分配给一个 javascript 变量,如上面 var=dir =new File("folder path"); 然后我们可以对路径执行任何操作。

于 2012-04-13T10:57:12.257 回答