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

时间:2022-03-14 20:43:58

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
      • Common (tab)
        • Standard Input and Output
        • 标准输入和输出
      • Common (tab)标准输入和输出。
    • Java应用程序Common (tab)标准输入和输出。
  • 运行配置Java应用程序通用(tab)标准输入和输出

there are 3 options

有三个选项

  • 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 }用法

${workspace_loc:/myworkspacesubfolder}/test.txt

$ { workspace_loc:/ myworkspacesubfolder } /用法

${workspace_loc:/myworkspacesubfolder}\test.txt

$ { workspace_loc:/ myworkspacesubfolder } \用法

...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:\用法

, but...)

,但是……)

What is the proper syntax for using "Workspace..."?

使用“工作区…”的正确语法是什么?

2 个解决方案

#1


1  

The proper syntax for this is: ${workspace_loc:/myworkspacesubfolder/test.txt} Make sure that you manually create test.txt file in that location. I is not created automatically by eclipse.

正确的语法是:${workspace_loc:/myworkspacesubfolder/test。确保您手动创建了测试。在那个位置的txt文件。我不是由eclipse自动创建的。

#2


0  

The correct syntax is ${workspace_loc:/myworkspacesubfolder}/test.txt. This works even when the file does not already exist.

正确的语法是${workspace_loc:/myworkspacesubfolder}/test.txt。即使这个文件不存在,它也可以工作。

See this Eclipse bug for an explanation of why ${workspace_loc:/myworkspacesubfolder/test.txt} doesn't work when the file doesn't already exist.

有关${workspace_loc:/myworkspacesubfolder/test的解释,请参见这个Eclipse bug。当文件不存在时,txt}不能工作。

#1


1  

The proper syntax for this is: ${workspace_loc:/myworkspacesubfolder/test.txt} Make sure that you manually create test.txt file in that location. I is not created automatically by eclipse.

正确的语法是:${workspace_loc:/myworkspacesubfolder/test。确保您手动创建了测试。在那个位置的txt文件。我不是由eclipse自动创建的。

#2


0  

The correct syntax is ${workspace_loc:/myworkspacesubfolder}/test.txt. This works even when the file does not already exist.

正确的语法是${workspace_loc:/myworkspacesubfolder}/test.txt。即使这个文件不存在,它也可以工作。

See this Eclipse bug for an explanation of why ${workspace_loc:/myworkspacesubfolder/test.txt} doesn't work when the file doesn't already exist.

有关${workspace_loc:/myworkspacesubfolder/test的解释,请参见这个Eclipse bug。当文件不存在时,txt}不能工作。