/*************************************************************************
* Compilation: javac StdOut.java
* Execution: java StdOut
*
* Writes data of various types to standard output.
*
*************************************************************************/ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Locale; /**
* <i>Standard output</i>. This class provides methods for writing strings
* and numbers to standard output.
* <p>
* For additional documentation, see <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by Robert Sedgewick and Kevin Wayne.
*
* @author Robert Sedgewick
* @author Kevin Wayne
*/
public final class StdOut { // force Unicode UTF-8 encoding; otherwise it's system dependent
private static final String CHARSET_NAME = "UTF-8"; // assume language = English, country = US for consistency with StdIn
private static final Locale LOCALE = Locale.US; // send output here
private static PrintWriter out; // this is called before invoking any methods
static {
try {
out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
}
catch (UnsupportedEncodingException e) { System.out.println(e); }
} // don't instantiate
private StdOut() { } // close the output stream (not required)
/**
* Close standard output.
*/
public static void close() {
out.close();
} /**
* Terminate the current line by printing the line separator string.
*/
public static void println() {
out.println();
} /**
* Print an object to standard output and then terminate the line.
*/
public static void println(Object x) {
out.println(x);
} /**
* Print a boolean to standard output and then terminate the line.
*/
public static void println(boolean x) {
out.println(x);
} /**
* Print a char to standard output and then terminate the line.
*/
public static void println(char x) {
out.println(x);
} /**
* Print a double to standard output and then terminate the line.
*/
public static void println(double x) {
out.println(x);
} /**
* Print a float to standard output and then terminate the line.
*/
public static void println(float x) {
out.println(x);
} /**
* Print an int to standard output and then terminate the line.
*/
public static void println(int x) {
out.println(x);
} /**
* Print a long to standard output and then terminate the line.
*/
public static void println(long x) {
out.println(x);
} /**
* Print a short to standard output and then terminate the line.
*/
public static void println(short x) {
out.println(x);
} /**
* Print a byte to standard output and then terminate the line.
*/
public static void println(byte x) {
out.println(x);
} /**
* Flush standard output.
*/
public static void print() {
out.flush();
} /**
* Print an Object to standard output and flush standard output.
*/
public static void print(Object x) {
out.print(x);
out.flush();
} /**
* Print a boolean to standard output and flush standard output.
*/
public static void print(boolean x) {
out.print(x);
out.flush();
} /**
* Print a char to standard output and flush standard output.
*/
public static void print(char x) {
out.print(x);
out.flush();
} /**
* Print a double to standard output and flush standard output.
*/
public static void print(double x) {
out.print(x);
out.flush();
} /**
* Print a float to standard output and flush standard output.
*/
public static void print(float x) {
out.print(x);
out.flush();
} /**
* Print an int to standard output and flush standard output.
*/
public static void print(int x) {
out.print(x);
out.flush();
} /**
* Print a long to standard output and flush standard output.
*/
public static void print(long x) {
out.print(x);
out.flush();
} /**
* Print a short to standard output and flush standard output.
*/
public static void print(short x) {
out.print(x);
out.flush();
} /**
* Print a byte to standard output and flush standard output.
*/
public static void print(byte x) {
out.print(x);
out.flush();
} /**
* Print a formatted string to standard output using the specified
* format string and arguments, and flush standard output.
*/
public static void printf(String format, Object... args) {
out.printf(LOCALE, format, args);
out.flush();
} /**
* Print a formatted string to standard output using the specified
* locale, format string, and arguments, and flush standard output.
*/
public static void printf(Locale locale, String format, Object... args) {
out.printf(locale, format, args);
out.flush();
} // This method is just here to test the class
public static void main(String[] args) { // write to stdout
StdOut.println("Test");
StdOut.println(17);
StdOut.println(true);
StdOut.printf("%.6f\n", 1.0/7.0);
} }

算法java(Robert Sedgewick)基本API-StdOut.java的更多相关文章

  1. 算法第四版 coursera公开课 普林斯顿算法 ⅠⅡ部分 Robert Sedgewick主讲《Algorithms》

    这是我在网上找到的资源,下载之后上传到我的百度网盘了. 包含两部分:1:算法视频的种子 2:字幕 下载之后,请用迅雷播放器打开,因为迅雷可以直接在线搜索字幕. 如果以下链接失效,请在下边留言,我再更新 ...

  2. [转载]Java 8 日期&时间 API

    Java 8 日期和时间 声明 本文转自http://www.journaldev.com/2800/java-8-date-localdate-localdatetime-instant,以mark ...

  3. Java基础知识强化99:Java 常见异常及趣味解释

    常见 Java 异常解释:(译者注:非技术角度分析.阅读有风险,理解需谨慎:) 1. java.langjava.lang软件包是java语言的核心部分,它提供了java中的基础类. java.lan ...

  4. 配置算法(第4版)的Java编译环境

    1. 下载 1.1 JDK http://www.oracle.com/technetwork/java/javase/downloads/index.html选择“Windows x64 180.5 ...

  5. Java高并发秒杀API之Service层

    Java高并发秒杀API之Service层 第1章 秒杀业务接口设计与实现 1.1service层开发之前的说明 开始Service层的编码之前,我们首先需要进行Dao层编码之后的思考:在Dao层我们 ...

  6. atitit.跨语言实现备份mysql数据库 为sql文件特性 api 兼容性java c#.net php js

    atitit.跨语言实现备份mysql数据库 为sql文件特性 api 兼容性java c#.net php js 1. 两个方法:: bat vs mysqldump(推荐)  vs   lang  ...

  7. 03.Java多线程并发库API使用2

    1.多个线程之间共享数据的方式探讨 1.如果每个线程执行的代码相同,可以使用同一个Runnable对象,这个Runnable对象中有那个共享数据,例如,买票系统就可以这么做. 2.如果每个线程执行的代 ...

  8. paip.文件读写api php java python总结.txt

    paip.文件读写api php java python总结.txt 一.多种方式读文件内容.    1.按字节读取文件内容   以字节为单位读取文件,常用于读二进制文件,如图片.声音.影像等文件. ...

  9. Java 8 Date Time API Example Tutorial – LocalDate, Instant, LocalDateTime, Parse and Format

    参考 Java 8 Date and Time API is one of the most sought after change for developers. Java has been mis ...

随机推荐

  1. 【转】删除已经存在的 TFS Workspace

    删除已经存在的 TFS Workspace 分类: TFS2010-03-03 16:59 1239人阅读 评论(2) 收藏 举报 serverpathcommandcachefilegoogle 工 ...

  2. JAVA自定义注释(Target,Retention,Documented,Inherit)

    java自定义注解 Java注解是附加在代码中的一些元信息,用于一些工具在编译.运行时进行解析和使用,起到说明.配置的功能.注解不会也不能影响代码的实际逻辑,仅仅起到辅助性的作用.包含在 java.l ...

  3. 结构类模式(七):代理(Proxy)

    定义 为其他对象提供一种代理以控制对这个对象的访问. 代理模式也叫做委托模式,它是一项基本设计技巧.许多其他的模式,如状态模式.策略模式.访问者模式本质上是在更特殊的场合采用了委托模式,而且在日常的应 ...

  4. Jackson 高性能的JSON处理 ObjectMapper

    http://blog.csdn.net/wangyang2698341/article/details/8223929 今天自行研究了下json ,感觉非常好用,经过测试比google的GSON快多 ...

  5. Python学习入门基础教程(learning Python)--5.1 Python下文件处理基本过程

    Python下的文件读写操作过程和其他高级语言如C语言的操作过程基本一致,都要经历以下几个基本过程. 1. 打开文件 首先是要打开文件,打开文件的主要目的是为了建立程序和文件之间的联系.按程序访问文件 ...

  6. VPS之openVPN的安装配置

    原文地址:http://www.blogjava.net/dongbule/archive/2010/11/01/336714.html 上次写的<VPS的购买和使用>中提到了openVP ...

  7. 动态链接库 仅有.dll文件时候的使用方法

    在没有.h和.lib文件时,需要函数指针和WIN32 API函数 LoadLibrary, GetProcAddress 和FreeLibrary 只需要.dll文件即可(将.dll文件置入工程目录中 ...

  8. Remobjects SDK 服务器搭建

    for delphi: 在工程文件源码中,有一个编译字 {#ROGEN: ***.rodl},将它的名字改成 指定的 rodl 即可自动生成相关文件,一般默认为 NewService.

  9. jQuery hover事件鼠标滑过图片半透明标题文字滑动显示隐藏

    1.效果及功能说明 hover事件制作产品图片鼠标滑过图片半透明,标题文字从左到右滑动动画移动显示隐藏 2.实现原理 首先把效果都隐藏,然后定义一个伪类来触发所有的效果,接下来当触发伪类后会有一个遍历 ...

  10. Oracle 自己主动诊断资料档案库 (ADR)、自己主动诊断工作流、ADRCI工具

    1.自己主动诊断工作流: 通过一个始终处于打开状态的内存中跟踪工具,数据库组件能够在第一次出现严重错误故障时捕获诊断数据.系统将自己主动维护一个称为"自己主动诊断资料档案库"的特殊 ...