'2009/11'에 해당되는 글 3건

  1. 2009/11/18 JAVA (redirection of standard output and error streams)
  2. 2009/11/13 JAVA Vector sorting
  3. 2009/11/01 In Duluth (with Shawn)
2009/11/18 04:49 My major/JAVA
 Redirection of the standard output and error streams to log files.

FileOutputStream fos = new FileOutputStream("out.stdout", true);
BufferedOutputStream bos = new BufferedOutputStream(fos);
System.setOut(new PrintStream(bos, true));
fos = new FileOutputStream("error.stderr", true);
bos = new BufferedOutputStream(fos);
System.setErr(new PrintStream(bos, true));

posted by joyoungtae
2009/11/13 04:03 My major/JAVA
1. Create target class for sorting and define compareTo() function

class TargetClass implements Comparable{
  int id;
  String name;
  public TargetClass(int id, String name){
    id = id;
    name = name;
  }
  public int compareTo(Object o){
    TargetClass tc = (TargetClass)o;
    if(this.id > tc.id)
      return 1;
    else if(this.id == tc.id)
      return 0;
    else
      return -1;
  }
}

2. sort
public class mainClass{
  public static void main(String argv[]){
    Vector<TargetClass> vec = new Vector<TargetClass> ();
    for(int i=10; i>0; i--){
      TargetClass item = new TargetClass(i, "jo"+i);
      vec.add(item);
    }
    Collections.sort(vec);
  }
}
posted by joyoungtae
2009/11/01 02:40 my life

with Shawn


With Shawn using digital camcoder in Seafarers Center that is down stair of my room.
posted by joyoungtae