如何正确强制Gradle进程回车(\ r)?

我有简单的代码和三个不同的输出。如何强制IDEA和/或Gradle处理回车?

#include <string>

struct Type {
    Type();
    Type(int);
    int theVal();
};

template<typename Key,typename Value,Key(*KeyFunc)(Type t) = nullptr>
struct MyClass {
    MyClass(){}

    ~MyClass(){}

    void add(const Key key,const Value value){
         //do stuff
    }

    void add(const Value value){
         this->add(KeyFunc(value),value);
    }
};

int main(){
    MyClass<
      int,std::string,+[](Type t){
        return t.theVal();
      }
    > instance;

    Type value(100);

    instance.add(value);

    return 0;
}
  1. Intellij Idea只是将“ \ r”解释为“ \ n”。而且什么也做不了。
  2. 命令“渐变运行” 在每行上破坏带有执行时间消息的输出。如果设置了“ --console = plain”,则消息消失,但“ \ r”变成“ \ n”。
  3. 只有普通的“ java MyApp.Main”才能正常工作。

如何正确强制Gradle进程回车(\ r)?

lihaizheng17 回答:如何正确强制Gradle进程回车(\ r)?

据我所知,您想打印与平台无关的换行符。在这种情况下,请查看this article,它描述了formatprintf。更具体地说:

Here is a basic example:

int i = 461012;
System.out.format("The value of i is: %d%n",i);
The %d specifies that the single variable is a decimal integer. The %n is a platform-independent newline character.
,

添加 System.out.flush() 修复了它。正如扎克·斯维尔斯所提到的

本文链接:https://www.f2er.com/3157071.html

大家都在问