250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 백준#BOJ#8012#한동이는영업사원
- 백준#boj#12755
- 백준#BOJ#12865#평범한배낭
- 백준#BOJ#2615#오목
- 백준#BOJ#1939#중량제한
- 백준#boj#16932#모양만들기
- 백준#BOJ#14501#퇴사#브루트포스
Archives
- Today
- Total
순간을 성실히, 화려함보단 꾸준함을
[자바 입출력] System.out.println()을 쓰지 말자! 본문
오늘 새롭게 알게 된 사실.....자바에서 입출력 할때 입력할때는 Scanner를 사용하지 말아야 된다는 건 알고 있었지만, sysout 또한 사용하면 안된다는 사실을 알 수 있었네요...ㅠㅠㅠ
1)sysout
package com.boj.practice;
/**
* IO Template reference : 류호석
*/
import java.io.*;
import java.nio.Buffer;
import java.util.*;
import java.util.concurrent.DelayQueue;
import static java.lang.Math.*;
public class Main{
static FastReader scan = new FastReader();
public static void main(String[] args) throws IOException{
int t=1;
//t = scan.nextInt();
while(t-->0)
solve();
}
static void solve() throws IOException{
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
long beforeTime = System.currentTimeMillis();
for (int i = 0; i < 1_000_000_000; i++) {
System.out.print("");
//bw.write("");
}
//bw.flush();
long afterTime = System.currentTimeMillis();
System.out.println("시간차이(m) : " + (afterTime-beforeTime));
}
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(new File(s)));
}
String next(){
while(st==null || !st.hasMoreElements()){
try{
st = new StringTokenizer(br.readLine());
}catch(IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
long nextLong(){
return Long.parseLong(next());
}
String nextLind(){
String str="";
try{
str=br.readLine();
}catch (IOException e){
e.printStackTrace();
}
return str;
}
}
}
시간차이(m) : 32021
2)BufferedWriter 사용
package com.boj.practice;
/**
* IO Template reference : 류호석
*/
import java.io.*;
import java.nio.Buffer;
import java.util.*;
import java.util.concurrent.DelayQueue;
import static java.lang.Math.*;
public class Main{
static FastReader scan = new FastReader();
public static void main(String[] args) throws IOException{
int t=1;
//t = scan.nextInt();
while(t-->0)
solve();
}
static void solve() throws IOException{
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
long beforeTime = System.currentTimeMillis();
for (int i = 0; i < 1_000_000_000; i++) {
//System.out.print("");
bw.write("");
}
bw.flush();
long afterTime = System.currentTimeMillis();
System.out.println("시간차이(m) : " + (afterTime-beforeTime));
}
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(new File(s)));
}
String next(){
while(st==null || !st.hasMoreElements()){
try{
st = new StringTokenizer(br.readLine());
}catch(IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
long nextLong(){
return Long.parseLong(next());
}
String nextLind(){
String str="";
try{
str=br.readLine();
}catch (IOException e){
e.printStackTrace();
}
return str;
}
}
}
시간차이(m) : 1143
'알고리즘,SQL > 백준,BOJ' 카테고리의 다른 글
[ boj : 14628 ] 입 챌린저 (0) | 2021.12.18 |
---|---|
[ boj : 23562 ] ㄷ 만들기 (0) | 2021.12.13 |
[Java8] Arrays.sort 람다(lambda)를 사용해서 내림차순 해보기 (0) | 2021.12.11 |
[ boj : 23560 ] 약 (0) | 2021.12.10 |
[ boj : 23559 ] 밥 (2) | 2021.12.10 |