ACM中Java高效输入输出封装
来自互联网 :
既高效又好用才是王道!
- import java.io.IOException;
- import java.io.FileInputStream;
- import java.io.InputStreamReader;
- import java.io.BufferedReader;
- import java.io.OutputStreamWriter;
- import java.io.PrintWriter;
- import java.io.StreamTokenizer;
- import java.util.ArrayList;
- import java.util.Collections;
- public class Main
- {
- public static final boolean DEBUG = false;
- public StreamTokenizer tokenizer;
- public BufferedReader cin;
- public PrintWriter cout;
- public void init()
- {
- try {
- if (DEBUG) {
- cin = new BufferedReader(new InputStreamReader(
- new FileInputStream("d:\\OJ\\uva_in.txt")));
- } else {
- cin = new BufferedReader(new InputStreamReader(System.in));
- }
- cout = new PrintWriter(new OutputStreamWriter(System.out));
- tokenizer = new StreamTokenizer(cin);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public String next()
- {
- try {
- tokenizer.nextToken();
- if (tokenizer.ttype == StreamTokenizer.TT_EOF)
- return null;
- else if (tokenizer.ttype == StreamTokenizer.TT_NUMBER) {
- return String.valueOf((int)tokenizer.nval);
- } else if (tokenizer.ttype == StreamTokenizer.TT_WORD) {
- return tokenizer.sval;
- } else return null;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
- public void solve(String s)
- {
- }
- public static void main(String[] args)
- {
- }
- }
作者:Pickle
声明:对于转载分享我是没有意见的,出于对博客园社区和作者的尊重一定要保留原文地址哈。
致读者:坚持写博客不容易,写高质量博客更难,我也在不断的学习和进步,希望和所有同路人一道用技术来改变生活。觉得有点用就点个赞哈。
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111112835275-168981902.gif)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111112841431-2047172832.jpg)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111112847494-1544911856.jpg)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111112904385-918783221.jpg)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111120143119-1302805212.jpg)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111112856369-1466718103.jpg)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111112830416-794416355.jpg)
![](https://images2015.cnblogs.com/blog/735119/201701/735119-20170111113919510-1155220901.gif)