开发者

I want to print any text without using Print function in java?

开发者 https://www.devze.com 2022-12-24 22:24 出处:网络
I want to print any text without using system.out.println() in j开发者_开发技巧ava? It is possible If yes

I want to print any text without using system.out.println() in j开发者_开发技巧ava? It is possible If yes then how; Any idea.


   System.out.write("text".getBytes());

   System.out.format("%s", "text");


Its actually possible and there is an awesome method to do it

make a class, call it so

make it like this

public class so
{
    public static void p(Object o){
        System.out.print(o);
    }
    public static void pln(Object o){
        System.out.println(o);
    }
}

then call the method like

so.pln("hi");

or

so.p("hi");

you can actually use it like an ordinary print or println function just writing lesser...

if you just done want to use println use print

like this

System.out.print("\n whatever you want");

\n takes it to the next line.........

Or what you can do is using your IDE go to the println function and do whatever is done in there.........


System.out in a PrintStream which is a kind of OutputStream. You can send raw bytes on that stream, if you wish it so. This is not recommended, because how raw bytes are handled depends on the host system and its configuration (the dreadful "locale" business). The print() and println() methods do "the right thing" for you.


What do you want to achieve? Are you looking for log4j logging?


System.out.logd("text") is pretty similar. If it's just the specific call you can't use or something.

0

精彩评论

暂无评论...
验证码 换一张
取 消