?? getconfig.java
字號:
/*
* Main.java
*
* 主服務器的開發從今天開始了從今天起 可能要遇到技術上的難題
* 但是這些是成長的經歷中必須要面臨的熟悉的資料已經熟悉的差不多了
* 開始進入了開發的階段
* 2008年1月3日, 下午2:22
*
*
*
*/
/*
* 程序員楊龍:本視頻會議服務器端代碼:根據自己定義的協議:能構穿透nat 需要java jmf框架
* 我開放源代碼是為了更好的讓java這門程序藝術更好的發展:您可以研究代碼,您可以自己使用
* 但是不要使用在商業用途上 讓我們更好的把開源事業在中國做下去
* 2008年 3月 楊龍 完成服務器端的框架
* 信箱 :y_flash@163.com
* QQ:274797328
* www.0351soft.com www.lx08.com
*/
package ytp.javaserver.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/
public class getConfig extends javax.swing.JFrame {
/** Creates new form getConfig */
public getConfig() {
initComponents();
}
public void reset()
{
try
{
jCip.removeAllItems();
String hostName = InetAddress.getLocalHost().getLocalHost().getHostName();
InetAddress[] inet = InetAddress.getAllByName(hostName);
for(int index=0;index<inet.length;index++) {
jCip.addItem(inet[index].getHostAddress());
}
File file = new File("config/config.dat");
if(file.exists())
{
//配置文件存在
FileInputStream fileIn = new FileInputStream(file);
int fileSize = fileIn.available();
byte[] byteRead = new byte[fileSize+1];
String strTemp = null;
//文件中有可以配置的信息
if(fileSize>0)
{
fileIn.read(byteRead);
strTemp = new String(byteRead); //構造配置文件字符串
String[] strs = strTemp.split("&");
for(int i=0; i<strs.length;i++)
{
//各自將信息寫入到需要的文件框中
if(strs[i].startsWith("IP:")||strs[i].startsWith("ip:"))
{
jLip.setText(strs[i].substring(3));
}
if(strs[i].startsWith("port:")||strs[i].startsWith("PORT:"))
{
jLport.setText(strs[i].substring(5));
}
if(strs[i].startsWith("configPath:")||strs[i].startsWith("ConfigPath:"))
{
jLconPath.setText(strs[i].substring(11));
}
if(strs[i].startsWith("Mediapath:")||strs[i].startsWith("Mediapath:"))
{
jLmediaPath.setText(strs[i].substring(10));
}
if(strs[i].startsWith("time:")||strs[i].startsWith("time:"))
{
jLinfo.setText("您上次配置服務器信息時間是:"+strs[i].substring(5));
}
}
}else //文件中沒有可以配置的信息
{
jLinfo.setText("您的服務器配置信息為空!請確認您已經配置過您的服務器:");
}
//讀入配置信息 填充到
}else
{
jLinfo.setText("您這是首次配置您的服務器!");
}
}catch(UnknownHostException e)
{
JOptionPane.showMessageDialog(this,e.toString());
}catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(this,e.toString());
}catch(IOException e)
{
JOptionPane.showMessageDialog(this,e.toString());
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代碼 ">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLip = new javax.swing.JLabel();
jLport = new javax.swing.JLabel();
jLmediaPath = new javax.swing.JLabel();
jLconPath = new javax.swing.JLabel();
jLtime = new javax.swing.JLabel();
jLinfo = new javax.swing.JLabel();
jCip = new javax.swing.JComboBox();
jLabel8 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel1.setText("\u67e5\u770b\u670d\u52a1\u5668\u914d\u7f6e\u4fe1\u606f");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jLabel2.setText("\u670d\u52a1\u5668IP\u5730\u5740:");
jLabel3.setText("\u670d\u52a1\u5668\u7aef\u53e3:");
jLabel4.setText("\u5a92\u4f53\u5b58\u653e\u5730\u5740:");
jLabel5.setText("\u914d\u7f6e\u6587\u4ef6\u5730\u5740:");
jLabel6.setText("\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u65f6\u95f4:");
jLabel7.setText("\u670d\u52a1\u5668\u73b0\u5728\u72b6\u6001:");
jLip.setText("jLabel8");
jLport.setText("jLabel8");
jLmediaPath.setText("jLabel8");
jLconPath.setText("jLabel8");
jLtime.setText("jLabel8");
jLinfo.setText("jLabel8");
jCip.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel8.setText("\u6240\u6709IP\u5217\u8868:");
jButton1.setText("\u4fee\u6539\u914d\u7f6e\u4fe1\u606f");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -