java通讯录全部代码!
import java.io.BufferedOutputStream;
创新互联主要从事成都网站建设、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务青阳,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
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通过一个数字找到匹配的手机号码怎么写代码
比如你拿到的数字是 number, 所有手机号码为 tele_nums,一个手机号码为tele_num;
。。。
String test = String.vlaueOf(number);
for(...) { //获取单个手机
if(tele_num.contains(test)) {
...
...这里面就已经过滤了
}
}
小女子跪求:如何用java实现电话号码查找
话说~~
如此大的测试集和苛刻的约束条件的随即生成,如果要用JAVA编译器来完成,那是件相当麻烦的事情,估计问问数据库方面的专家比较好.
编写程序,提供图形交互界面进行号码速查:
这个功能用JAVA就很好做了,好象楼上说的,Swing,DAO方面,如果是用SQL语句的话,做个模糊查询就可以了.
"界面要求美观大方,可参考金山词霸界面。"估计Swing还不够...
这个项目如果我做出来了,拿个界面做个模板去卖,估计可以换1个星期的烟钱.
java程序代码实现手机号码归属地查询,求源码?
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class Test {
public static void main(String[] args) throws IOException {
String mobile = "手机号码";
String url = ";mobile=%s";
url = String.format(url, mobile);
Document doc = Jsoup.connect(url).get();
Elements els = doc.getElementsByClass("tdc2");
System.out.println("归属地:" + els.get(1).text());
System.out.println("类型:" + els.get(2).text());
System.out.println("区号:" + els.get(3).text());
System.out.println("邮编:" + els.get(4).text().substring(0, 6));
}
}
网站栏目:java查询电话代码 java查询手机号归属地
当前链接:http://scgulin.cn/article/doiohdc.html