Java与ActionScript的Socket(1)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cn.vicky.socket;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Vector;
/**
*
* @author Vicky
* 广播类
*/
public class BManager extends Vector<Socket> {
/**
* 对所有已经连接上的socket发送消息
* @param msg
* @throws IOException
*/
public synchronized void sendToAll(String msg) throws IOException {
Socket socket = null;
PrintWriter writer = null;
for (int i = 0; i < size(); i++) {
socket = get(i);
if (socket != null) {
writer = new PrintWriter(socket.getOutputStream(),true);
if (writer != null) {
writer.println(msg);
}
}
}
}
/**
* 向某个人发送消息
* @param msg
* @param socket
* @throws IOException
*/
public synchronized void sendToOne(String msg, Socket socket) throws IOException {
PrintWriter writer = null;
if (socket != null && contains(socket)) {
writer = new PrintWriter(socket.getOutputStream(),true);
if (writer != null) {
writer.println(msg);
}
}
}
/**
* 向所有人发送当前在线人数
* @throws IOException
*/
public synchronized void sendInfo() throws IOException {
String msg = "当前人数:" + size() + "人";
sendToAll(msg);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cn.vicky.socket;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Vicky
* 聊天系统服务器
*/
public class ChatServer {
private static final Logger logger
相关文档:
List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1 List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......
2008 年 6 月 24 日
原文地址: http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0806wangys/
本文介绍 IBM FileNet P8 4.0 Platform 提供的 Content Java API。首先对 FileNet P8 Content Engine 和 API 进行概要介绍, 并说明了一些基本概念,随后详细介绍了 FileNet Content Engine提供的基于 EJB ......
最近公司碰到需要用图表的形式显示一些数据,我就开始到网上查询,查到了jfreechart和amcharts,这两者我都实现过了,jfreechart最后生成图片,但是图片效果不是我想要的,然后又研究amcharts 它的效果确实很好,而且官方网站上还有好些例子可供下载,网址是:www.amcharts.com
(想要完成一个amcharts图形需要swfobjects. ......
由于公司项目的需要,最经在研究Quercus一个纯java的php引擎。项目这两个需要做的就是将该引擎裁剪,做一个相对安全的版本,提供给ISV使用,同时,在引擎中提供默认的接口供调用。所以先研究了一下,在Quercus引擎的支持下,PHP如何与java集成。
以下是学习到的几点:
1、如果使用 Resin-IoC/WebBeans来组织应用的服 ......
package com.hefeng.test;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.uti ......