首页 > 代码库 > ACM中Java高效输入输出封装
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)
- {
- }
- }
ACM中Java高效输入输出封装
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。