[Java]从一个Updater中学到的
来源:互联网 发布:最全的化合物数据库 编辑:程序博客网 时间:2024/04/27 23:25
10年5月,在做作业的闲暇时间利用Intelligent Web上学到的知识,学了一个Updater,可以从某网站上获取新更新的图片,读取到本地后可以选择浏览或下载。虽然这个工具现在基本没有使用了,但是从中还是学习到很多基础技术要点。
在Java中使用正则表达式
String rgxTitle = "<span class=\"filetitle\">(.+?)<";Pattern ptnTitle = Pattern.compile(rgxTitle);Matcher mtcTitle = ptnTitle.matcher(this.content);if (mtcTitle.find())return mtcTitle.group(1);elsereturn "";
建立一个网络连接并读取URL页面内容
URL u = new URL("http://www.google.com");BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
读取图片并显示
URL u = new URL("http://www.google.com/title.jpg");Image image=ImageIO.read(u);ImageIcon ic = new ImageIcon(image);JLabel label =new JLabel(ic);
下载
FileOutputStream fos = null;BufferedInputStream bis = null;HttpURLConnection httpUrl = null;byte[] buf = new byte[8096];int size = 0;httpUrl = (HttpURLConnection) u.openConnection();httpUrl.connect();bis = new BufferedInputStream(httpUrl.getInputStream());fos = new FileOutputStream("Save\\" + filename + ".jpg");while ((size = bis.read(buf)) != -1)fos.write(buf, 0, size);fos.close();bis.close();httpUrl.disconnect();
Clipboard sysc = Toolkit.getDefaultToolkit().getSystemClipboard();Transferable tText = new StringSelection(new String("Sample Text")); sysc.setContents(tText, null);
- [Java]从一个Updater中学到的
- 从一个项目中学到的
- 从一个递归程序中学到的
- 从生活中学到的
- 从dota中学到的
- 从面试中学到的
- 我们能从Java的HelloWorld中学到什么?
- 我们能从Java的HelloWorld中学到什么?
- 我们可以从Java的HelloWorld中学到什么?
- 从《循环的代价》中学到的
- 从两个团队中学到的
- 从yii权威指南中学到的
- 关于BroadcastReceiver从SDK中学到的
- 从《亮剑》中学到的管理方法
- 从完成《JAVA编程思想》第四版 流程控制 练习10的过程中学到的
- 工作中学到的雜七雜八 -- JAVA
- Effictive Java中学到的一些常识
- 从真正的程序员中学到的东西。
- linux正则表达式 grep egrep用法
- QT&OpenCV
- dev -c++ 快捷键
- 数组循环移位
- line 1: Dump: command not found
- [Java]从一个Updater中学到的
- POJ 3386 Halloween Hoildays(我的水题之路——两个戒指)
- java设计模式之工厂模式
- 浏览器扩展系列————异步可插入协议(pluggable protocol)的实现
- android学习笔记转--------------上下左右与返回键的按键捕捉事件
- SQL Server 2008 的安装与卸载
- Install ncurses-devel on Ubuntu 9.4
- 2011-2012寒假总结
- 数据结构基础(2)-->栈