Java output printing tool encapsulation and java tool Encapsulation

Source: Internet
Author: User

Java output printing tool encapsulation and java tool Encapsulation

When I print the output in Java and view the field value, I feel that the System is written every time. out. after the official release of println, I had to delete them one by one, which was too troublesome. After some suggestions, I made a Java printing and output encapsulation class, just to record this tool class. Not to mention, post code

1 package com. dyf. utils; 2/** 3 * Description: encapsulation output printing, set the print switch 4 * @ author diy 5*6 */7 public class SysoUtils {8 9 private static final boolean DEBUG = true; // output switch 10 11/** 12 * Description: Used to debug the output, replacing syso tool class 13 * Note: static method, use the class name to call 14 * use this tool class, please pay attention to rewrite tostring (), if you need to define other output styles, please modify the value of the 15 * Switch DEBUG switch to determine whether to switch the output. 16 * @ param args Variable Parameter List 17 */18 public static void print (Object... args) {19 if (DEBUG) {20 for (Object arg: args) {21 System. out. println (arg); 22} 23 System. out. println (); 24} 25} 26 27/* 28 * Description: or if only the string type is printed, use the following 29 private static final boolean DEBUG = false; 30 31 public static void p (String s) {32 if (DEBUG) {33 System. out. println (s); 34} 35} 36 */37 38}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.