public class Test {
/**
* @param args
* @throws java.text.ParseException
*/
public static void main(String[] args) throws java.text.ParseException {
// Date dateNow = new Date();
//
// String dateNowStr = dateFormat.format(dateNow);
// System.out.println(dateNowStr);
final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五",
"星期六" };
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
Calendar calendar = Calendar.getInstance();
Date date = new Date();
String datarq = dateFormat.format(date); //日期
calendar.setTime(date);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if (dayOfWeek < 0)
dayOfWeek = 0;
System.out.println(datarq + " " + dayNames[dayOfWeek]);
}
}
posted @
2011-12-22 15:07 冯占科 阅读(141) |
评论 (0) |
编辑 收藏
开始–运行–cmd 进入命令提示符 输入netstat -ano 即可看到所有连接的PID 之后在任务管理器中找到这个PID所对应的程序如果任务管理器中没有PID这一项,可以在任务管理器中选”查看”-”选择列”
经常,我们在启动应用的时候发现系统需要的端口被别的程序占用,如何知道谁占有了我们需要的端口,很多人都比较头疼,下面就介绍一种非常简单的方法,希望对大家有用。
我们需要确定谁占用了我们的80端口
在windows命令行窗口下执行:
C:\>netstat -aon|findstr “80″
TCP 0.0.0.0:19780 0.0.0.0:0 LISTENING 2044
TCP 10.72.224.5:2558 96.17.109.8:80 ESTABLISHED 2044
TCP 10.72.224.5:2757 60.210.176.209:80 TIME_WAIT 0
TCP 10.72.224.5:3956 125.46.1.234:80 ESTABLISHED 2044
TCP 10.72.224.5:3959 125.46.1.234:80 ESTABLISHED 2044
UDP 0.0.0.0:2280 *:* 3700
看到了吗,端口被进程号为2044的进程占用,继续执行下面命令:
C:\>tasklist|findstr “2044″
avp.exe 2044 Console 0 37,680 K
很清楚吧,avp 卡巴监听80端口,调整卡巴网络监听设置。
当然,如果你的80端口被其他程序占用,kill掉或者调整端口。
posted @
2011-01-17 16:20 冯占科 阅读(481) |
评论 (0) |
编辑 收藏
package l6;
/**
* 实现栈的数据结构
*/
import java.util.LinkedList;
public class MyStack {
LinkedList mylist = new LinkedList();
public void push(Object o) {
mylist.addFirst(o);
}
public Object pop() {
return mylist.removeFirst();
}
public Object peek() {
return mylist.getFirst();
}
public boolean empty() {
return mylist.isEmpty();
}
public static void main(String[] args) {
MyStack ms = new MyStack();
ms.push("1");
ms.push("2");
ms.push("3");
ms.push("4");
System.out.println(ms.pop());
System.out.println(ms.pop());
System.out.println(ms.peek());
System.out.println(ms.empty());
}
}
package l6;
import java.util.LinkedList;
/**
* 实现队列的数据结构
*
*/
public class MyQueue {
private LinkedList ll = new LinkedList();
public void put(Object o) {
ll.addLast(o);
}
public Object get() {
return ll.removeFirst();
}
public Object peek() {
return ll.getFirst();
}
public boolean empty() {
return ll.isEmpty();
}
/**
* @param args
*/
public static void main(String[] args) {
MyQueue mq = new MyQueue();
mq.put("1");
mq.put("2");
mq.put("3");
mq.put("4");
mq.put("5");
mq.put("6");
System.out.println(mq.get());
System.out.println(mq.get());
System.out.println(mq.get());
System.out.println(mq.get());
System.out.println(mq.peek());
System.out.println(mq.empty());
}
}
posted @
2011-01-13 22:48 冯占科 阅读(244) |
评论 (0) |
编辑 收藏
//学生类
package l6;
import java.util.Comparator;
public class Student implements Comparable {
public int num;
public String name;
public Student(int num, String name) {
this.num = num;
this.name = name;
}
public int compareTo(Object o) {
Student s = (Student) o;
if (num > s.num) {
return 1;
} else if (num == s.num) {
return 0;
} else {
return -1;
}
}
public String toString() {
return "num:" + num + " name:" + name;
}
public int compare(Object o1, Object o2) {
// TODO Auto-generated method stub
return 0;
}
}
//学生比较器
package l6;
import java.util.Comparator;
public class StudentComparator implements Comparator {
public int compare(Object o1, Object o2) {
Student s1 = (Student) o1;
Student s2 = (Student) o2;
if (s1.num > s2.num) {
return 1;
} else if (s1.num < s2.num) {
return -1;
} else {
return s1.name.compareTo(s2.name);
}
}
}
//测试类
package l6;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
public class ArrayListTest {
/**
* @param args
*/
public static void main(String[] args) {
ArrayList<Student> slist = new ArrayList<Student>();
Student s1 = new Student(1, "z1");
slist.add(s1);
Student s3 = new Student(2, "z3");
slist.add(s3);
Student s2 = new Student(2, "z2");
slist.add(s2);
Student s5 = new Student(2, "z5");
slist.add(s5);
Student s4 = new Student(4, "z4");
slist.add(s4);
// Collections.sort(slist); //未使用比较器
Collections.sort(slist, new StudentComparator());//未使用比较器
PaintE(slist);
}
public static void PaintE(Collection c) {
Iterator it = c.iterator();
while(it.hasNext()){
System.out.println(it.next().toString());
}
}
}
posted @
2011-01-12 23:01 冯占科 阅读(211) |
评论 (0) |
编辑 收藏