【问题标题】:Play framework Windows v's Linux file path播放框架Windows v的Linux文件路径
【发布时间】:2015-04-18 23:50:12
【问题描述】:

我在我的 Windows PC 上开发了一个 Play 框架应用程序,然后将其传输到我的 Linux 机器上,我正在将视频和照片上传到服务器,这个上传过程在我的 Windows PC 上完美运行,但没有在 Linux 机器上工作。

我在 windows 中使用的代码:

        String root = Play.application().path().toString();
        String globalFolderPath = root + "/public/globalUploadFolder/";
        File globalFolder = new File(globalFolderPath);

我在 Linux 中尝试过的代码以及上面的代码:

            String globalFolderPath = "../../public/globalUploadFolder/";
            File globalFolder = new File(globalFolderPath);

对于 Linux 机器上不同的文件路径,我需要做些什么,这可能是权限问题吗?

我不知道为什么会这样。

【问题讨论】:

  • 关于您在 globalFolderPath 变量中使用的分隔符。尝试使用 File.separator。
  • 是否有错误或异常?
  • @user1929959 File.separator 似乎不起作用。
  • @Diego 没有错误或异常
  • 好的,那doesn't work 是什么意思?另外,关于您发布的代码,它与问题有什么关系? File 对象是如何使用的?我认为您需要为其他人提供更多信息才能提供帮助

标签: java linux playframework


【解决方案1】:

使用File.separator解决了问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-18
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    相关资源
    最近更新 更多