Java UDP通讯程序升级版
最近一直在写C#的UDP通讯方面的程序,抽空把以前写的Java的UDP通讯程序拿出来做了一些升级的修改,把以前一些不足的地方做了改动,同时使用exe4j软件编译成exe文件,软件效果如下所示:
同时把代码贴出来,以供大家指点一二。
Main.java(主函数)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jappudp;
/**
*
* @author AlimysoYang
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
UdpFrame udpframe = new UdpFrame();
}
}
UdpFrame.java(窗口单元)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jappudp;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author AlimysoYang
* @version 1.0.1
*/
public class UdpFrame extends JFrame implements ActionListener
{
//初始化窗口控件
private JLabel lbRecvPort = new JLabel("接收端口",JLabel.LEFT);
private JLabel lbSendIP = new JLabel("发送IP",JLabel.LEFT);
private JLabel lbSendPort = new JLabel("发送端口",JLabel.LEFT);
private JLabel lbRecv = new JLabel("接收数据",JLabel.LEFT);
private JLabel lbSend = new JLabel("发送数据",JLabel.LEFT);
private JLabel lbInfo = new JLabel("",JLabel.LEFT);
private JLabel lbVersion = new JLabel("AlimysoYang (for NetBeans) v1.01",JLabel.LEFT);
private JTextField tfRecvPort = new JTextField("8800",6);
private JTextField tfSendIP = new JTextField("127.0.0.1",15);
private JTextField tfSendPort = new JTextField("8801",6);
相关文档:
用的是MySQL数据库。
1,建一个userdb库,再建userinfo表,字段:id(int),username(varchar),password(varchar)。
create database userdb;
use userdb;
create table userinfo(
id int(10) not null auto_increment,
username varchar(20),
password varchar(20),
primary key(id));
2,DBConnection.jav ......
2010-04-26 22:36
import java.util.Scanner;
public class _calendar {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("请输入年份:");
Scanner sc = new Scanner(System.in);
int year = sc.nextInt(); ......
package com.sy.grasp;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpression {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
......
凌宇 在www.360doc.com中转帖【IEEE浮点数表示法】,经过仔细研究,终于有点心得了。
float转十六进制:
16进制浮点数的表示方法,根据IEEE的标准,分为32位和64位两种,参数分别如下:
符号位
指数位
指数偏移量
尾数位
32位
1[31]
8[23-30]
23[0-22]
127
64位
1[63]
11[52-62]
52 ......