java如何搜索代码,java怎么找到对应的代码

JAVA中怎么实现查询 代码

try{Connection con;

东明网站建设公司创新互联公司,东明网站设计制作,有大型网站制作公司丰富经验。已为东明数千家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的东明做网站的公司定做!

Statement stmt;

ResultSet rs;

int temp;

Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/java","root","");//以上是数据库连接,不同的数据管理器有 //不同的驱动和链接方式,以上是mysql的连接

stmt=con.createStatement();

rs=stmt.executeQuery("select * from student");//执行查询语句,结果赋值给结果集rs

//结果集是结果于字段编号的映射,每一个字

//段都有一个编号,最小为1,也就是第一个字段

while(rs.next()){

String names=rs.getString("name");//查询结果转换成字符串。

System.out.println(names);

}rs.close();

}catch(Exception e){

e.printStackTrace();

}

怎样在网上查找JAVA源代码

用百度搜索一下,就用“JAVA源代码“做为搜索条件。一般能找到很多网站。

要学JAVA最好还是找本书看一看。JAVA能做的东西很多,你要决定你的主攻方向然后就去找相应的资料。

你要学哪方面:

JAVA应用程序开发,

JAVA网络开发:JSP,APPLET。

JAVA手持设备软件开发,像手机软件等。

如果对程序还不是很懂,最好找本JAVA入门级的书看看,然后再决定。

java搜索文件的代码怎么写,返回文件的路径?求教

你是搜文件名,还是搜文件内容?要是搜文件内容可就麻烦了,有可能的话你看看Java的一个开源库Lucene。

要是简单的搜文件名包含的字符串,大致应该涉及到文件树的遍历算法,最多用一些简单的正则表达式来匹配文件名,一般用递归可以实现任意级目录树的搜索。

给你个简单的版本吧:

package test.tool;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public class FindFile {

private String fileName = "";

private String dir = "";

private Matcher m = null;

private int count = 0;

public FindFile() throws IOException {

String f = FindFile.class.getResource("findfile.properties").getFile();

BufferedReader read = new BufferedReader(new FileReader(f));

dir = read.readLine().trim();

fileName = read.readLine().trim();

Pattern p = Pattern.compile(fileName);

m = p.matcher("");

}

public void find() {

File root = new File(dir);

for (File f : root.listFiles()) {

if (f.isDirectory()) {

dir = f.getAbsolutePath();

find();

} else {

m.reset(f.getName());

if (m.find()) {

count++;

System.out.println(f.getAbsolutePath());

}

}

}

}

public static void main(String[] args) {

try {

FindFile ff = new FindFile();

ff.find();

System.out.println("\n共找到文件数目:" + ff.count);

} catch (IOException e) {

e.printStackTrace();

}

}

}

里面用到的findfile.properties,举个例子:

F:\download

vod.*.exe

运行效果如下:

F:\download\firefox\vodplayer.exe

F:\download\ie\vodplayer.exe

共找到文件数目:2

java如何实现搜索功能。比如,输入txt就能搜索出这个文件夹内所有txt格式的文件。请给完整代码。

import java.io.*;

public class FileDemo{

public static void main(String[] args)throws Exception{

//第一个参数是文件路径,第二个参数是要搜索的文件扩展名

getFile("D:\\JavaDemo",".txt");

}

private static void getFile(String pathName, final String endsWith)throws Exception{

File file = new File(pathName);

if(!file.exists())

throw new RuntimeException("文件不存在,你检索个P呀。");

file.listFiles(new FileFilter(){

public boolean accept(File file){

if(file.getName().endsWith(endsWith)){

System.out.println(file.getName());

return true;

}else

return false;

}

});

}

}

java代码,怎么查看?

java查某个类的源码可以通过jar包

例如查看java.lang.Integer源代码

把src解压了就行了啊,然后打开解压后的src文件夹下的java/long/ 就有Integer.java文件了

JAVA中怎么查询代码?

try{Connection con;

Statement stmt;

ResultSet rs;

int temp;

Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/java","root","");//以上是数据库连接,不同的数据管理器有 //不同的驱动和链接方式,以上是mysql的连接

stmt=con.createStatement();

rs=stmt.executeQuery("select * from student");//执行查询语句,结果赋值给结果集rs

//结果集是结果于字段编号的映射,每一个字

//段都有一个编号,最小为1,也就是第一个字段

while(rs.next()){

String names=rs.getString("name");//查询结果转换成字符串。

System.out.println(names);

}rs.close();

}catch(Exception e){

e.printStackTrace();

}


当前名称:java如何搜索代码,java怎么找到对应的代码
网页网址:http://myzitong.com/article/hddjji.html