http://qola.springnote.com/pages/24914
java.lang.ProcessBuilder
-----------------------------------------------------------------------------------
Runtime.exec 보다 간단한 방법으로 서브 프로세스를 호출
ex)
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Map<String, String> env = pb.environment();
env.put("VAR1", "myValue");
env.remove("OTHERVAR");
env.put("VAR2", env.get("VAR1") + "suffix");
pb.directory("myDir");
Process p = pb.start();
java.util.Formatter
----------------------------------------------------------------------------------
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb, Locale.US);
// Explicit argument indices may be used to re-order output.
formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d")
// -> " d c b a"
// Optional locale as the first argument can be used to get
// locale-specific formatting of numbers. The precision and width can be
// given to round and align the value.
formatter.format(Locale.FRANCE, "e = %+10.4f", Math.E);
// -> "e = +2,7183"
// The '(' numeric flag may be used to format negative numbers with
// parentheses rather than a minus sign. Group separators are
// automatically inserted.
formatter.format("Amount gained or lost since last statement: $ %(,.2f",
balanceDelta);
// -> "Amount gained or lost since last statement: $ (6,217.58)"
java.util.Scanner
----------------------------------------------------------------------------------
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
Scanner sc = new Scanner(new File("myNumbers"));
while (sc.hasNextLong()) { long aLong = sc.nextLong();
}
String input = "1 fish 2 fish red fish blue fish";
Scanner s = new Scanner(input). useDelimiter("\\s*fish\\s*");
// "\s* : 0 또는 하나 이상의 공백 반각 스페이스
System.out.println(s.nextInt());
System.out.println(s.nextInt());
System.out.println(s.next());
System.out.println(s.next());
s.close();
String input = "1 fish 2 fish red fish blue fish";
Scanner s = new Scanner(input);
s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)");
MatchResult result = s.match();
for (int i=0;i<=result.groupCount();i++) { // groupCount(): 정규 표현 그룹의 수
System.out.println(result.group(i)); // group() 일치한 입력 부분
}
s.close();
-->
1 fish 2 fish red fish blue
1
2
red
blue
java.util.concurrent
----------------------------------------------------------------------------------
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html
http://kr.sun.com/developers/techtips/c2005_0216.html
( Semaphore, CountDownLatch, Exchanger 를 이용한 동기화 )
http://sangchin.byus.net/FlashHelp/Java_util_concurrent/fixedworkqueue.html
( Creating a Bounded Work Queus )
http://www.java2s.com/Code/JavaAPI/java.util.concurrent/Catalogjava.util.concurrent.htm
( CyclicBarrier , Executors, ExecutorService, TimeUnit 샘플)
http://www.informit.com/articles/article.asp?p=335378&rl=1
(Using the new Concurrent Utility Classes in Java 5.0)
java.lang.ProcessBuilder
-----------------------------------------------------------------------------------
Runtime.exec 보다 간단한 방법으로 서브 프로세스를 호출
ex)
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Map<String, String> env = pb.environment();
env.put("VAR1", "myValue");
env.remove("OTHERVAR");
env.put("VAR2", env.get("VAR1") + "suffix");
pb.directory("myDir");
Process p = pb.start();
java.util.Formatter
----------------------------------------------------------------------------------
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb, Locale.US);
// Explicit argument indices may be used to re-order output.
formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d")
// -> " d c b a"
// Optional locale as the first argument can be used to get
// locale-specific formatting of numbers. The precision and width can be
// given to round and align the value.
formatter.format(Locale.FRANCE, "e = %+10.4f", Math.E);
// -> "e = +2,7183"
// The '(' numeric flag may be used to format negative numbers with
// parentheses rather than a minus sign. Group separators are
// automatically inserted.
formatter.format("Amount gained or lost since last statement: $ %(,.2f",
balanceDelta);
// -> "Amount gained or lost since last statement: $ (6,217.58)"
java.util.Scanner
----------------------------------------------------------------------------------
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
Scanner sc = new Scanner(new File("myNumbers"));
while (sc.hasNextLong()) { long aLong = sc.nextLong();
}
String input = "1 fish 2 fish red fish blue fish";
Scanner s = new Scanner(input). useDelimiter("\\s*fish\\s*");
// "\s* : 0 또는 하나 이상의 공백 반각 스페이스
System.out.println(s.nextInt());
System.out.println(s.nextInt());
System.out.println(s.next());
System.out.println(s.next());
s.close();
String input = "1 fish 2 fish red fish blue fish";
Scanner s = new Scanner(input);
s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)");
MatchResult result = s.match();
for (int i=0;i<=result.groupCount();i++) { // groupCount(): 정규 표현 그룹의 수
System.out.println(result.group(i)); // group() 일치한 입력 부분
}
s.close();
-->
1 fish 2 fish red fish blue
1
2
red
blue
java.util.concurrent
----------------------------------------------------------------------------------
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html
http://kr.sun.com/developers/techtips/c2005_0216.html
( Semaphore, CountDownLatch, Exchanger 를 이용한 동기화 )
http://sangchin.byus.net/FlashHelp/Java_util_concurrent/fixedworkqueue.html
( Creating a Bounded Work Queus )
http://www.java2s.com/Code/JavaAPI/java.util.concurrent/Catalogjava.util.concurrent.htm
( CyclicBarrier , Executors, ExecutorService, TimeUnit 샘플)
http://www.informit.com/articles/article.asp?p=335378&rl=1
(Using the new Concurrent Utility Classes in Java 5.0)
'java' 카테고리의 다른 글
jad 옵션 (0) | 2008.06.05 |
---|---|
NIO FileCopy (0) | 2008.05.15 |
java.util.Properties - loadFromXML (0) | 2008.05.15 |
날짜 (0) | 2008.05.14 |
utf-8 인코딩을 이용한 한글 url 처리 (0) | 2006.10.27 |