简单通讯录java代码,java简单通讯录管理系统-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

简单通讯录java代码,java简单通讯录管理系统

实现一个小型通讯录。Java

Friend类:public class Friend {

公司主营业务:网站制作、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出射洪免费做网站回馈大家。

/*

* 姓名

*/

private String name;

/*

* 电话

*/

private String telephone;

/*

* 邮箱

*/

private String email;

/*

* 公司

*/

private String company; public String getName() {

return name;

} public void setName(String name) {

this.name = name;

} public String getTelephone() {

return telephone;

} public void setTelephone(String telephone) {

this.telephone = telephone;

} public String getEmail() {

return email;

} public void setEmail(String email) {

this.email = email;

} public String getCompany() {

return company;

} public void setCompany(String company) {

this.company = company;

} public String toString() {

StringBuffer str = new StringBuffer(); str.append("姓名:" + name).append("\n");

str.append("电话:" + telephone).append("\n");

str.append("邮箱:" + email).append("\n");

str.append("公司:" + company).append("\n");

str.append("-----------------------------------------\n");

return str.toString();

}

}AddFriend类:public class AddFriend { /**

* 主方法 程序的入口

*/

public static void main(String[] args) {

ListFriend friendList = new ArrayListFriend();

char isGo = 'Y';

int i = 0;

do {

Friend friend = new Friend();

System.out.println("请输入第" + (i + 1) + "位朋友的姓名:");

InputStreamReader reader = new InputStreamReader(System.in);

String str = "";

try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

friend.setName(str); System.out.println("请输入第" + (i + 1) + "位朋友的电话:"); try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

if (str.matches("\\d*") str.length() == 11) {// 判断用户输入的电话是否符合标准

friend.setTelephone(str);

} else {

System.out.println("电话号码输入有误,请重新输入!");

continue;

} System.out.println("请输入第" + (i + 1) + "位朋友的邮箱:"); try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

friend.setEmail(str); System.out.println("请输入第" + (i + 1) + "位朋友的公司:"); try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

friend.setCompany(str); friendList.add(friend); i++; System.out.println("是否继续添加?(Y/N):");

String go = "";

try {

go = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

isGo = go.charAt(0);

} while (isGo == 'Y' || isGo == 'y'); for (int j = 0; j friendList.size(); j++) {

System.out.println(friendList.get(j).toString());

}

}

}

java通讯录全部代码!

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.Scanner;

public class AddList {

private String filePath = "";

private String bakPath = "";

private String content = "";

Scanner sc = new Scanner(System.in);

public String readFile(){

content = "";

if (isNull(filePath)) {

System.out.println("文件存储路径:");

filePath = sc.nextLine();

}

File file = new File(filePath);

FileReader fr = null;

try {

if (file.exists()) {

fr = new FileReader(file);

char[] chars = new char[1024];

int n = 0;

while((n = fr.read(chars)) != -1){

String string = new String(chars, 0, n);

content = content + string;

}

} else {

System.out.println("文件不存在");

}

} catch (Exception e) {

e.printStackTrace();

} finally {

if (fr != null) {

try {

fr.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

return content;

}

public void writeFile(String path){

File file = new File(path);

FileOutputStream fos = null;

mkDirs(path);

try {

fos = new FileOutputStream(file);

BufferedOutputStream bos = new BufferedOutputStream(fos);

PrintWriter pw = new PrintWriter(bos, true);

pw.print(content);

pw.flush();

} catch (FileNotFoundException e) {

e.printStackTrace();

} finally {

if (fos != null) {

try {

fos.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

public void writeFile(){

if (isNull(filePath)) {

System.out.println("文件存储路径:");

filePath = sc.nextLine();

}

File file = new File(filePath);

FileOutputStream fos = null;

mkDirs(filePath);

try {

fos = new FileOutputStream(file);

BufferedOutputStream bos = new BufferedOutputStream(fos);

PrintWriter pw = new PrintWriter(bos, true);

pw.print(content);

pw.flush();

} catch (FileNotFoundException e) {

e.printStackTrace();

} finally {

if (fos != null) {

try {

fos.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

public void mkDirs(String filepath){

if (filepath.indexOf("\\") != -1) {

filepath = filepath.replaceAll("\\", "/");

}

int n = filepath.indexOf("//");

String path = filepath.substring(0, n) + "//";

filepath = filepath.substring(filepath.indexOf("//") + 1, filepath.length());

String[] files = filepath.split("/");

for (int i = 0; i files.length - 1; i++) {

path = path + files[i];

File file = new File(path);

if (!file.exists()) {

file.mkdir();

}

}

}

public void addImfor(){

System.out.println("--------增加记录---------");

String name = "";

String tel = "";

String email = "";

content = readFile();

while(true){

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

name = sc.next();

System.out.println("电话:");

tel = sc.next();

System.out.println("Email:");

email = sc.next();

content = content + name + "" + tel + "" + email +"==";

System.out.println("0、Exit 1、继续");

int i = sc.nextInt();

if (i == 0) {

break;

}

}

writeFile();

}

public void deleteImfor(){

System.out.println("---------删除记录---------");

String name = "";

String[] imfors = null;

content = readFile();

while(true){

System.out.println("你要删除的姓名是:");

name = sc.next();

if (content.indexOf(name) != -1) {

imfors = content.split("==");

for (int i = 0; i imfors.length; i++) {

if (imfors[i].indexOf(name) != -1) {

imfors[i] = "";

}

}

用JAVA编写一个班级通讯录

1)java form,jlable 、textField、button 神马 的 GridBagLayout布局搞一发

2)JDBC 往数据库搞一搞;

3)数据库排序取出,或者取出后代码排个序

4)步骤2已经写入数据库,下次从数据库区,不会丢失

5)搞一个方法,专门用于显示,每计算一次,调用这个方法

另;应该搞个登陆的,管理总要有权限控制的


新闻名称:简单通讯录java代码,java简单通讯录管理系统
网址分享:http://kswsj.cn/article/dsgoeoi.html

其他资讯