上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: 现在好多网站都有图片搜索的功能现在java有个开源项目 为Lire 的,他是基于Lucene 3.3.0 的官网:http://www.semanticmetadata.net/lire/现在写下他的使用方法他有十三个Builder ,他们分别从不同的角度对图片做分析(当然你的Builder也可以只填一种)可以分别根据他们的Search方法来 查出各自角度的相似图片进行排序让后从相似度由大到小返回回来 ,首先举个例子,对某个文件夹里的图片建立索引,将他的名字保存到document里 descriptorImageIdentifier (这个在源码里可以看见)域里indexSource 是图片的 阅读全文
posted @ 2013-01-04 09:47 杨桃 阅读(1356) 评论(0) 推荐(0) 编辑
摘要: 创建索引的例子:package com.test;import java.io.File;import java.io.IOException;import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.standard.StandardAnalyzer;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;import org.apache.lucene.index.IndexWriter 阅读全文
posted @ 2013-01-02 17:15 杨桃 阅读(323) 评论(0) 推荐(0) 编辑
摘要: public static String[] split(String s, String token) { if (s == null) return null; if (token == null || s.length() == 0) return new String[] { s }; int size = 0; String[] result = new String[4]; while (s.length() > 0) { int index = s.indexOf(token); String splitOne = s; if (index > -1... 阅读全文
posted @ 2013-01-02 16:11 杨桃 阅读(735) 评论(0) 推荐(0) 编辑
摘要: java 将内容写到文件中的代码 public static void write(List pingpai) { try { File file = new File("C:/Users/Administrator/Desktop/品牌/Mp3.txt"); FileWriter fw = new FileWriter(file, true); for (String string : pingpai) { fw.append("\n\r" + string + "\n\r"); } fw.flush(); fw.close(); 阅读全文
posted @ 2013-01-02 16:03 杨桃 阅读(326) 评论(0) 推荐(0) 编辑
摘要: java语句插入数据库的时候,如果string 中含有单引号则可以用下面代码转换为双引号,也可以直接去掉(string.replace("\'",""))// 改变单引号 public static String changeSingleQuotes(String orderString) { String newString = ""; char[] ch = orderString.toCharArray(); for (int i = 0; i < ch.length; i++) { if (ch[i] == &# 阅读全文
posted @ 2013-01-02 15:58 杨桃 阅读(1193) 评论(0) 推荐(0) 编辑
摘要: java 将一个句子的多个空格变成想要替换的字符public static String changeMoreSpace(String order) { String now = ""; String[] s = order.split(" "); for (String string : s) { if (!string.equals("")) { now += string + " "; } } // System.out.println(now); return now; }在now += string + 阅读全文
posted @ 2013-01-02 15:53 杨桃 阅读(738) 评论(0) 推荐(0) 编辑
摘要: java将中文Url转换为浏览器识别的编码用到了URLEncoder.encode解码的话用到URLDecoder代码如下:public static String changeHanzi(String url) { char[] tp = url.toCharArray(); String now = ""; for (char ch : tp) { if (ch >= 0x4E00 && ch <= 0x9FA5) { try { now += URLEnco... 阅读全文
posted @ 2013-01-02 15:42 杨桃 阅读(1036) 评论(0) 推荐(0) 编辑
摘要: 显示某个数据库下的所有表public List showTables() { List tables = new ArrayList(); try { PreparedStatement stmt = null; Connection conn = null; conn = ConnectionTools.getConn(); conn.setAutoCommit(false); String sql = "show tables"; stmt = conn.prepareStatement(sql); ResultSet rs = stmt.executeQu... 阅读全文
posted @ 2013-01-02 15:37 杨桃 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 有两个推荐网址:http://www.open-open.com/jsoup/http://www.iteye.com/topic/1010581这两个队jsoup简单使用做了很好的指导我只提出比较实用的例子:当我们读取某些网址被屏蔽返回505 时可以尝试用一下代码// 读取URL public static Document readUrlFistT(String url) { Document doc = null; try { doc = Jsoup.connect(url).timeout(60 * 1000).userAgent( "Mozilla/4.0 (comp... 阅读全文
posted @ 2013-01-02 15:20 杨桃 阅读(2050) 评论(0) 推荐(0) 编辑
摘要: package com.util;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.util.HashSet;import java.util.Set;public class LoadUserWords { public static Set loadUserWords(InputStream input) { String line; Set myWords = new HashS.. 阅读全文
posted @ 2013-01-02 14:01 杨桃 阅读(676) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 下一页