zoukankan      html  css  js  c++  java
  • 打印类

    主要包含字节打印类(PrintStream)字符打印流(PrintWriter).

    可以打印任何的数据类型,如小数、整数、字符串等

    格式化的输出方式,使用printf()方法完成

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.PrintStream;
    
    //=================================================
    // File Name       :	Print_demo
    //------------------------------------------------------------------------------
    // Author          :	Common
    
    
    
    
    
    //主类
    //Function        : 	Print_demo
    public class Print_demo {
    
    	public static void main(String[] args) throws Exception{
    		// TODO 自动生成的方法存根
    		PrintStream ps = null;		
    		//通过FileOutputStream实例化,意味着所有的输出都是向文件中打印
    		ps = new PrintStream(new FileOutputStream(new File("/home/common/software/coding/HelloWord/HelloWord/test.txt")));
    		String name = "张三";
    		int age = 30;
    		float score = 90.123f;
    		char sex = 'M';
    		
    		ps.print("Hello");
    		ps.print("Word");
    		//格式化输出,字符使用%s,整数使用%d,小数使用%f,字符使用%c
    		ps.printf("姓名:%s,年龄:%d,成绩:%f,性别:%c",name,age,score,sex);
    		ps.close();
    	}
    
    }
    
  • 相关阅读:
    skywalking物理拓扑图
    检测HTTPS证书到期时间
    docker zipkin 链路监控
    定时任务和任务-示例
    小程序列表循环出来的list是不同接口赋的值
    小程序编辑器报-50003错误肿么办?
    uni-app小程序组建
    2019
    春日
    Mac安装软件提示破损
  • 原文地址:https://www.cnblogs.com/tonglin0325/p/5277446.html
Copyright © 2011-2022 走看看