简体   繁体   English

在Eclipse中,如何使用“ Workspace…”语法(例如$ {workspace_loc:/ myworkspace})指定文件(用于控制台日志)?

[英]In Eclipse, how do you specify a file using the “Workspace…” syntax (e.g. ${workspace_loc:/myworkspace} ) (for a console log)?

I was following the instructions in this answer: View deleted console output 我正在按照此答案中的说明进行操作: 查看已删除的控制台输出

(to set up a file in which Eclipse will record everything that goes to the console (too bad that is not done by default!) ), and under: (要设置一个文件,Eclipse将在其中记录去往控制台的所有内容(很遗憾,默认情况下未完成!) ),并位于以下位置:

  • Run Configurations 运行配置
    • Java Application Java应用
      • Common (tab) 普通(标签)
        • Standard Input and Output 标准输入输出

there are 3 options 有3个选择

  • Workspace... 工作区...
  • File System... 文件系统...
  • Variables... 变量...

I wanted to use "Workspace...", and I selected my workspace, which generated text like this in the text box: 我想使用“工作区...”,然后选择了我的工作区,该工作区在文本框中生成了这样的文本:

${workspace_loc:/myworkspacesubfolder} $ {workspace_loc:/ myworkspacesubfolder}

I wanted to specify the file name, and I tried all of these forms: 我想指定文件名,然后尝试了所有以下形式:

${workspace_loc:/myworkspacesubfolder}test.txt $ {workspace_loc:/ myworkspacesubfolder}的test.txt

${workspace_loc:/myworkspacesubfolder}/test.txt $ {workspace_loc:/ myworkspacesubfolder} /test.txt

${workspace_loc:/myworkspacesubfolder}\\test.txt $ {workspace_loc:/ myworkspacesubfolder} \\ test.txt的

...but none of them worked. ...但是他们都不起作用。 (No errors alerts were thrown, but neither was the text file generated upon running the program.) (没有引发错误警报,但是运行程序时也没有生成文本文件。)

(I then gave up and used "File System..." instead of "Workspace...", which takes a standard path such as (然后我放弃了使用“文件系统...”而不是“工作区...”,它采用了标准路径,例如

C:\\test.txt C:\\ test.txt的

, but...) ,但是...)

What is the proper syntax for using "Workspace..."? 使用“工作区...”的正确语法什么?

The proper syntax for this is: ${workspace_loc:/myworkspacesubfolder/test.txt} Make sure that you manually create test.txt file in that location. 正确的语法是:$ {workspace_loc:/myworkspacesubfolder/test.txt}确保在该位置手动创建test.txt文件。 I is not created automatically by eclipse. 我不是由Eclipse自动创建的。

The correct syntax is ${workspace_loc:/myworkspacesubfolder}/test.txt . 正确的语法是${workspace_loc:/myworkspacesubfolder}/test.txt This works even when the file does not already exist. 即使该文件尚不存在,此方法也有效。

See this Eclipse bug for an explanation of why ${workspace_loc:/myworkspacesubfolder/test.txt} doesn't work when the file doesn't already exist. 请参阅此Eclipse错误 ,以解释当文件不存在时${workspace_loc:/myworkspacesubfolder/test.txt}为什么不起作用的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM