본문 바로가기

System

[Java] System 클래스 nanoTime(); import java.util.*; public class NanoTimeTest{ public static void main(String[] args) { long cur = System.nanoTime(); /* for문을 돌려 시간 때우기*/ for(int i =0; i < 100000000; i++){} double elapsedTime=(System.nanoTime()-cur)/1000000.0; System.out.println(elapsedTime); } } /* - static long nanoTime(); 현재의 시간을 ns로 리턴한다(1/1,000,000,000 초) 이 메소드는 JDK 5.0 부터 추가됨 */ 더보기
[Java] System 클래스 currentTimeMillis() import java.util.*; public class CutTimeMillisTest{ public static void main(String[] args) { long cur1 = System.currentTimeMillis(); /* for문을 돌려 시간 때우기*/ for(int i =0; i < 100000000; i++){} long elapsedTime=System.currentTimeMillis()-cur1; System.out.println(elapsedTime); } } /* - static long currentTimeMillis(); 현재의 시간을 ms로 리턴한다(1/1,000초) */ 더보기
[Java] System 클래스 GetEnv() import java.util.*; public class GetEnv{ public static void main(String[] args) { Map envMap=System.getenv(); Set key = envMap.keySet(); Iterator it = key.iterator(); while(it.hasNext()){ String curKey = it.next().toString(); System.out.format("%s=%s\n", curKey, envMap.get(curKey)); } } } /* - static Map getenv(); 현재 시스템 환경을 스트링 형태의 맵으로 리턴한다. - static String getenv(String name); name에 지정된 환경 변수의.. 더보기
[Java] System 클래스 getProperties() import java.util.*; public class GetProperties{ public static void main(String[] args){ System.setProperty("addProperty", "Test System Method"); Properties prop = System.getProperties(); Set key = prop.keySet(); Iterator it = key.iterator(); while(it.hasNext()){ String curKey = it.next().toString(); System.out.format("%s=%s\n", curKey, prop.getProperty(curKey)); } } } /* - static Properties getP.. 더보기
[Java] System 클래스 arraycopy() public class SystemArrayCopy{ public static void main(String[] args){ String[] arr = {"AAA","BBB","CCC","DDD","EEE"}; String[] copyArr = new String[3]; System.arraycopy(arr, 2, copyArr, 1, 2); for(String value: copyArr){ System.out.println(value); } } } /* static void arraycopy(Object arr, int arrPos, Object copyArr, int copyPos, int length); 특정 배열을 복사할 때 사용한다. 여기서 arr는 복사 원본배열, copyArr는 복사한 값이 .. 더보기