Java - Mac / Windows with System.out.println() [英] Java - Mac/Windows with System.out.println()

查看:137
本文介绍了Java - Mac / Windows with System.out.println()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们大多使用System.out.println在我们的IDE的控制台。我使用Eclipse。
我也可以清楚地看到我的Mac的控制台应用程序的println()消息。

We all mostly use System.out.println in the Console of our IDE. I am using Eclipse. I can also clearly see the println() message on my Mac's Console app. Which is nice for my personal things.

这里是代码:

public class Main {

    public static void main(String[] args) {

        System.out.println("Is this logged anywhere?");

    }

}

我在我的Mac上看到:

And here's what I see on my Mac:

Windows是否有类似于Mac版本的Console?

Does Windows have something similar to the Mac's version of Console?

推荐答案

很遗憾,如前所述,我们在Windows上没有。你最好的选择是从CMD运行你的程序,然后把标准导出到一个文件。像java -jar HelloWorld.jar> hello.txt。

Sadly, as previously said, we don't really have that on Windows. Your best options is to run your program from CMD and then pipe the standard out to a file. Something like java -jar HelloWorld.jar > hello.txt.

我通常做的是创建一个处理程序到一个日志文件(通常只是[程序名] log [日期] .txt,并根据日志输出所有消息如果你习惯只使用System out打印,这是一个好的习惯。

What I usually do is create a Handler to a log file (usually just [program name] log [date].txt and have all messages outputted there depending on the log level, which is good practice if you're used to only using System out prints.

简单的答案是没有这样的功能是标准的Windows。以某种方式管道到文件。

Straightforward answer remains that no such functionality comes standard with Windows. You'll have to pipe to a file in some manner.

这篇关于Java - Mac / Windows with System.out.println()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆