久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

java中地址管理代碼 java中地址管理代碼是什么

java通訊錄管理系統(tǒng)設(shè)計(jì)代碼怎么編譯

java編寫這個通訊錄管理系統(tǒng)

興化ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

java編寫這個通訊錄管理系統(tǒng)_Java如何實(shí)現(xiàn)通訊錄管理系統(tǒng)

咕嚕嚕在芬蘭

原創(chuàng)

關(guān)注

3點(diǎn)贊·2305人閱讀

Java如何實(shí)現(xiàn)通訊錄管理系統(tǒng)

發(fā)布時間:2020-07-28 09:39:42

來源:億速云

閱讀:65

作者:Leah

這篇文章將為大家詳細(xì)講解有關(guān)Java如何實(shí)現(xiàn)通訊錄管理系統(tǒng),文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

本文實(shí)例為大家分享了java實(shí)現(xiàn)通訊錄管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

完成項(xiàng)目的流程:

1.根據(jù)需求,確定大體方向

2.功能模塊分析

3.界面實(shí)現(xiàn)

4.功能模塊設(shè)計(jì)

5.coding

6.代碼測試

下面是源代碼:import java.awt.Container;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Scanner;

import java.util.concurrent.SynchronousQueue;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.WindowConstants;

import javax.swing.text.html.HTMLDocument.Iterator;

class Infro{

public String id;

public String name;

public String sex;

public String address;

public String e_mail;

public String phoneNumber;

static int index = 0;

static ArrayList list = new ArrayList();

static int len = list.size();

//構(gòu)造函數(shù)

public Infro(String id,String name,String sex,String address,String e_mail,String phoneNumber){

this.id = id;

this.name = name;

this.sex = sex;

this.address = address;

this.e_mail = e_mail;

this.phoneNumber = phoneNumber;

}

public String toString(){

return "編號:"+id+" 姓名:"+name+" 性別:"+sex+" 通訊地址:"+address+" 郵箱地址:"+e_mail+" 電話:"+phoneNumber;

}

/**

* 添加功能

**/

public static void addFunction(){//添加功能

Infro infro = new Infro("","","","","","");

System.out.println("請輸入添加的數(shù)據(jù):");

Scanner in = new Scanner(System.in);

System.out.println("輸入編號:");

infro.id = in.next();

System.out.println("輸入姓名:");

infro.name = in.next();

System.out.println("輸入性別:");

infro.sex = in.next();

System.out.println("輸入通訊地址:");

infro.address = in.next();

System.

out.println("輸入郵箱地址:");

infro.e_mail = in.next();

System.out.println("輸入電話:");

infro.phoneNumber = in.next();

list.add(index,infro);

index++;

if(list.isEmpty()){

System.out.println("數(shù)據(jù)添加失敗啦");

}else{

System.out.println("數(shù)據(jù)添加成功啦");

len++;//list集合長度加一

// System.out.println(list.get(0).toString());

}

}

// public static void deleteFunction(){//刪除功能

// System.out.println("輸入要刪除的聯(lián)系人的編號");

// Scanner in_2 = new Scanner(System.in);

// String d1 = in_2.nextLine();

// for(int a= 0; a

// if(d1.equals(list.get(a).id)){

// list.remove(list.get(a));

// len --;

// }

// }

// }

/**

* 刪除功能

**/

public static void deleteFunction(){

System.out.println("輸入要刪除的聯(lián)系人的編號");

Scanner in_2 = new Scanner(System.in);

String d1 = in_2.nextLine();

java.util.Iterator it = list.iterator();

while (it.hasNext()){

Infro infro = it.next();

if (infro.id.equals(d1)){

it.remove();

--index;//一定要加這個,否則當(dāng)做了刪除操作再做添加操作的時候會出現(xiàn)異常(類似于指針,棧)

System.out.println("刪除完畢"+"此時通訊錄記錄條數(shù)為:" + --len);

}

}

}

/**

* 修改功能

**/

public static void reditFunction(){

System.out.println("輸入要修改的通訊錄的Id");

Scanner in_r = new Scanner(System.in);

String r1 = in_r.nextLine();

for(int a = 0; a len;a++){

if(r1.equals(list.get(a).id)){

System.out.println("輸入修改后的姓名:");

String name_1 = in_r.next();

list.get(a).name = name_1;

System.out.println("輸入修改后的性別:");

String sex_1 = in_r.next();

list.get(a).sex = sex_1;

System.out.println("輸入修改后的通訊地址:");

String address_1 = in_r.next();

list.get(a).address = address_1;

System.out.println("輸入修改后的郵箱地址:");

String e_mail_1 = in_r.next();

list.get(a).e_mail = e_mail_1;

System.out.println("輸入修改后的電話:");

String phoneNumber_1 = in_r.next();

list.get(a).phoneNumber = phoneNumber_1;

System.out.println("數(shù)據(jù)修改完畢");

}

}

}

/**

* 查詢功能

**/

public static void searchFunction() throws Exception{//查詢功能

System.out.println("請輸入要查詢的姓名:");

Scanner in_1 = new Scanner(System.in);

String s1=in_1.nextLine();

for(int a= 0; a

if(s1.equals(list.get(a).name)){

System.out.println(list.get(a).toString());

}

}

}

/**

* 顯示功能

**/

public static void showFunction(){

for(int i = 0 ;i

System.out.println(list.get(i).toString());

}

}

/**

* 保存功能

**/

public static void writeFunction() throws IOException{

FileWriter writer = new FileWriter("通訊錄管理.txt");

for(int i = 0 ;i

String []strwriter = new String[len];

strwriter[i]=list.get(i).toString();

writer.write(strwriter[i]);

writer.write("\r\n");

System.out.println("成功寫入一行數(shù)據(jù)到 通訊錄管理.txt 中");

}

writer.close();//關(guān)閉寫入流,釋放資源

}

/**

* 讀取功能

**/

public static void readFunction() throws IOException{

FileReader reader = new FileReader("通訊錄管理.txt");

BufferedReader br = new BufferedReader(reader);

String str;

while((str = br.readLine()) != null){//每次讀取一行文本,判斷是否到達(dá)文件尾

System.out.println(str);

}

br.close();

}

}

public class Demo extends JFrame {

/**

* 界面設(shè)計(jì)

**/

public Demo(){

Container c = getContentPane(); //定義一個頂級容器c

JPanel jp = new JPanel(); //新建JPanel面板--jp

JButton button1 = new JButton("新建聯(lián)系人");

JButton button2 = new JButton("刪除聯(lián)系人");

JButton button3 = new JButton("編輯聯(lián)系人");

JButton button4 = new JButton("查找聯(lián)系人");

JButton button5 = new JButton("顯示所有聯(lián)系人");

JButton button6 = new JButton("保存聯(lián)系人到本地");

JButton button7 = new JButton("讀取本地聯(lián)系人");

jp.setLayout(new GridLayout(2,4,5,5));//新建網(wǎng)格布局管理器(行數(shù),列數(shù),組件間的水平垂直間距)

jp.add(button1);

jp.add(button2);

jp.add(button3);

jp.add(button4);

jp.add(button5);

jp.add(button6);

jp.add(button7);

c.add(jp);//將JPanel面板jp添加到頂級容器c中

setSize(600,500);

setTitle("*通 訊 錄 管 理 系 統(tǒng)*");

setVisible(true);

setResizable(false);//窗體大小由程序員決定,用戶不能自由改變大小

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

/**

*按鍵響應(yīng)

*

**/

button1.addActionListener(new ActionListener(){//添加功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.addFunction();

}

});

button2.addActionListener(new ActionListener(){//刪除功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.deleteFunction();

}

});

button3.addActionListener(new ActionListener(){//修改功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.reditFunction();

}

});

button4.addActionListener(new ActionListener(){//查詢功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

try {

Infro.searchFunction();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

button5.addActionListener(new ActionListener(){//顯示功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.showFunction();

}

});

button6.addActionListener(new ActionListener(){//保存功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

try {

Infro.writeFunction();

} catch (IOException e) {

e.printStackTrace();

}

}

});

button7.addActionListener(new ActionListener(){//讀取功能實(shí)現(xiàn)

public void actionPerformed(ActionEvent arg0){

try {

Infro.readFunction();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

}

public static void main(String[] args) {

// TODO Auto-generated method stub

new Demo();

Infro a = new Infro("", "", "", "", "", "");

}

}

關(guān)于Java如何實(shí)現(xiàn)通訊錄管理系統(tǒng)就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

運(yùn)行時可調(diào)用瀏覽器打開一個網(wǎng)頁,網(wǎng)頁地址在代碼中的java代碼怎么寫?

網(wǎng)頁地址在代碼中的java代碼寫法如下:

packagecom.test;

importjava.lang.reflect.Method;

//實(shí)現(xiàn)打開瀏覽器并跳到指定網(wǎng)址的類

publicclassBareBonesBrowserLaunch{

publicstaticvoidopenURL(Stringurl){

try{

browse(url);

}catch(Exceptione){

}

}

privatestaticvoidbrowse(Stringurl)throwsException{

//獲取操作系統(tǒng)的名字

StringosName=System.getProperty("os.name","");

if(osName.startsWith("MacOS")){

//蘋果的打開方式

ClassfileMgr=Class.forName("com.apple.eio.FileManager");

MethodopenURL=fileMgr.getDeclaredMethod("openURL",newClass[]{String.class});

openURL.invoke(null,newObject[]{url});

}elseif(osName.startsWith("Windows")){

//windows的打開方式。

Runtime.getRuntime().exec("rundll32url.dll,FileProtocolHandler"+url);

}else{

//UnixorLinux的打開方式

String[]browsers={"firefox","opera","konqueror","epiphany","mozilla","netscape"};

Stringbrowser=null;

for(intcount=0;countbrowsers.lengthbrowser==null;count++)

//執(zhí)行代碼,在brower有值后跳出,

//這里是如果進(jìn)程創(chuàng)建成功了,==0是表示正常結(jié)束。

if(Runtime.getRuntime().exec(newString[]{"which",browsers[count]}).waitFor()==0)

browser=browsers[count];

if(browser==null)

thrownewException("Couldnotfindwebbrowser");

else

//這個值在上面已經(jīng)成功的得到了一個進(jìn)程。

Runtime.getRuntime().exec(newString[]{browser,url});

}

}

}

//主方法測試類

publicstaticvoidmain(String[]args){

Stringurl="";

BareBonesBrowserLaunch.openURL(url);

}

C#或Java怎么修改內(nèi)存地址的值,給個代碼要有注釋?

C#和Java 都對指針進(jìn)行了封裝 C#我記得叫委托 Java叫引用

我熟悉Java就說Java

Java的引用是不能像C語言的指針一樣進(jìn)行++的操作 也不能隨便的想跳到什么位置就跳什么位置

修改地址 String c=“hi”;

c=“hello”;這就是例子

變量c是在棧內(nèi)存中的 他開始存的是堆內(nèi)存中“hi”的字符串的內(nèi)存地址 變?yōu)椤癶ello”字符串的內(nèi)存地址 至于“hi” “hello”到地內(nèi)存地址是多少 沒辦法知道 這樣做是為了安全 屏蔽細(xì)節(jié)

而且根據(jù)我對Java虛擬機(jī)的研究 你知道Java有垃圾回收機(jī)制吧 可以肯定的告訴你有些對象在堆內(nèi)存中的地址不會一直不變的 因?yàn)槔厥?要把某些對象要在內(nèi)存中“搬來搬去”

java中如何獲取用戶的IP地址及禁止此人

樓上的方法是不合理的。第一,如果用戶使用代理,是無法獲得真實(shí)Ip的0;第二,IF語句不能保證禁止IP,而且很多網(wǎng)站并不需要登錄的。給樓主些方法,可供參考。

1。 獲取用戶IP

public String getRemortIP(HttpServletRequest request) {

if (request.getHeader("x-forwarded-for") == null) {

return request.getRemoteAddr();

}

return request.getHeader("x-forwarded-for");

}

這種方法總是獲得用戶的真實(shí)IP

2。禁止IP,可以考慮從服務(wù)器下手

(1) 如果用的是tomcat,那么在tomcat_home/conf/server.xml中的host/host之間加一行代碼:

Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.1.1"/

這樣192.168.1.1這個ip訪問webapp時會收到 403 錯誤

(2) 如果是apache那么:

Directory /var/web/dir1

Allow from all

Deny from 111.111.111.111

/Directory

上面限制單個IP,限制IP段用*號代替。如111.111.111.*

(3) 或者樓主也可以像樓上說的用代碼實(shí)現(xiàn),給你個JS代碼:

SCRIPT LANGUAGE="java script"

!-- Begin

netscape = (navigator.appName.indexOf("Netscape") != -1);

version4 = (navigator.appVersion.indexOf("4.") != -1);

if (netscape version4) {

ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();

if (ip.indexOf("235.12") = -1)

// 這是想要禁止訪問的IP例如: 235.12.xxx.xxx

{

alert("You are not permitted to access this site.");

history.go(-1);

}

}

// End --

/script

將以上代碼加入到head區(qū)域中。

本文標(biāo)題:java中地址管理代碼 java中地址管理代碼是什么
當(dāng)前路徑:http://www.sd-ha.com/article14/docjgge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站移動網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、品牌網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)