- 浏览: 467531 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (371)
- Java (44)
- Flex (25)
- Design Pattern / UML (5)
- JVM (14)
- Software Engineer (4)
- Testing (30)
- Web Backend (60)
- Linux (7)
- Database (11)
- SOA (28)
- English (6)
- FX (5)
- SAP Support (25)
- SAP Development (5)
- SAP Impl & Oprn (8)
- Articles (15)
- Music (4)
- Recipe (14)
- Multi-thread (4)
- Lucene (2)
- CS basic / Algorithm (12)
- Tour (3)
- C C++ (21)
- Others (10)
- Code Repository C++ (1)
- Code Repository Java (1)
- Code Repository Algorithm (1)
- Code Repository SQL (1)
- Web Frontend (4)
最新评论
-
xiangxm:
Java 强引用、 软引用、 弱引用、虚引用 -
nml-lyb:
123
Mule 的第一个例子 -
nml-lyb:
http://www.baidu.com
Mule 的第一个例子 -
white___ant:
...
Java 强引用、 软引用、 弱引用、虚引用 -
joeyon:
...
Java NIO介绍
1. Properties ResourceBundle类的路径问题
System.out.println(System.getProperty("user.dir")); //这个是去工程的绝对路径的
System.out.println(Thread.currentThread().getContextClassLoader().getResource(""));//这个是去当 前classpath的uri的!
new Properties().load(new FileInputStream("test.properties"));//这里说明test文件在工程的跟目录下!
new Properties().load(new FileInputStream("test/test.properties"));//说明,在工程底下的test的文件夹底下的文件test.properties!
ResourceBundle rs = ResourceBundle.getBundle("org.hello");//这里说明,hello文件就是在于classpath底下的,org包底下有这个文件hello.properties~也就是说.../bin/这个是classpath绝对路径!
2、一个http请求的头部
GET /index.html HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */* Accept-Language: en-us,zh-cn;q=0.5 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 2.0.50727) Host: localhost:8080 Connection: Keep-Alive
out.println("GET http://fxcm.fx-performance.com/SystemTickets.aspx?bkr=1"
+ "&SystemID=" + systemID + "&InstrumentID=" + instrumentID
+ "&FromDate=20090101&ToDate=20090701 HTTP/1.0");
out.println("Host: " + "fxcm.fx-performance.com");
out.println("User-Agent: " + "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
out.println("Accept: " + "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
out.println("Accept-Language: " + "en-us,zh-cn;q=0.5");
//out.println("Accept-Encoding: " + "gzip,deflate");
out.println("Accept-Charset: " + "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
out.println("Keep-Alive: " + "300");
out.println("Proxy-Connection: " + "keep-alive");
//out.println("Cookie: " + "BCSI-CSA9B5F27E=2; BCSI-CSA9B5CE25=2");
out.println("Cache-Control: " + "max-age=0");
out.println("");// 这句很关键,告诉server这段话说完了。然后server端的in.readLine的while循环才能跳出向后执行。
private void fetchData() {
Socket socket = null;
PrintWriter out = null;
BufferedReader in = null;
String fromServer = "";
while (1 == 1) {
try {
Thread.sleep(10000);
socket = new Socket("webproxy.ssmb.com", 8080);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.println("GET http://www.dailyfx.com.hk/informer/fxcm_pricedde_sc.php?temp=1");
out.println("Host: www.dailyfx.com.hk");
out.println("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
out.println("Accept-Language: en-us");
out.println("Accept-Encoding: gzip,deflate");
out.println("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7");
out.println("Keep-Alive: 300");
out.println("Proxy-Connection: keep-alive");
out.println("");
while ((fromServer = in.readLine()) != null) {
System.out.print(fromServer);
}
System.out.println();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
in.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
3、inputstream to string
input是一个InputStream的对象。 public void parse() { // Read a set of characters from the socket StringBuffer request = new StringBuffer(2048); int i; byte[] buffer = new byte[2048]; try { i = input.read(buffer); } catch (IOException e) { e.printStackTrace(); i = -1; } for (int j = 0; j < i; j++) { request.append((char) buffer[j]); } System.out.print(request.toString()); uri = parseUri(request.toString()); }
发表评论
-
java8 Stream Lazy 解释 (非实现原理)
2015-07-22 07:49 1582http://blog.csdn.net/dm_vincen ... -
java8 系列2 深入理解Java 8 Lambda(类库篇——Streams API,Collectors和并行)
2015-07-22 07:00 2481http://zh.lucida.me/blog/java ... -
java8 系列1 深入理解Java 8 Lambda(语言篇——lambda,方法引用,目标类型和默认方法)
2015-07-22 06:58 1067http://zh.lucida.me/blog/java- ... -
Java 8 Stream探秘 具体实现
2015-07-22 06:31 896http://colobu.com/2014/11/18/J ... -
Arrays.asList() 的了解
2015-07-21 23:05 1161为什么Arrays.asList() 返回的list是 i ... -
java8 Lambda expressions
2015-07-14 13:09 876The single most important chan ... -
java8 new features
2015-07-08 02:06 700http://www.javacodegeeks.com/2 ... -
ReentrantLock与synchronized
2014-09-02 23:34 548http://uule.iteye.com/blog/148 ... -
PriorityQueue的使用
2014-05-29 12:14 958http://blog.csdn.net/yangzhon ... -
java的移位操作详解,左移和右移 << >>, 补码计算
2014-04-17 10:28 807---------------------补码--- ... -
深入Java集合学习系列:ArrayList的实现原理
2014-02-13 09:04 564http://zhangshixi.iteye.com/bl ... -
java集合类 ------------ 实现 细节
2014-02-12 23:12 532深入Java集合学习系列:ArrayList的 ... -
两种简单的方式快速实现hashCode 和 equals方法
2014-02-04 10:46 647http://hi.baidu.com/coolcat_p ... -
集合类 Set
2013-12-30 03:50 504http://www.cnblogs.com/yuchao ... -
java1.5新特性
2013-10-23 10:59 6701.自动包装和解包(Autoboxing and unboxi ... -
正则表达式30分钟入门教程
2013-10-22 00:21 543http://blog.csdn.net/cumt168/a ... -
总结Java方法(函数)传值和传引用的问题
2013-09-16 08:38 614http://java.chinaitlab.com/bas ... -
有状态,无状态对象是什么概念
2013-06-21 06:00 1118http://blog.csdn.net/showwair/ ... -
Dom4j的使用(全而好的文章)
2013-06-09 21:12 540http://xhy0422.iteye.com/blog/ ... -
serialVersionUID 用来表明类的不同版本间的兼容性
2013-06-03 23:12 814http://blog.csdn.net/hulefei29 ...
相关推荐
以上只是一部分可能包含在"Tricks of the Java Programming Gurus"中的知识点。这些技巧可以帮助开发者成为真正的Java编程大师,提升代码质量,降低维护成本。深入学习和实践这些技巧,将使你在Java开发道路上...
TRICKS OF THE JAVA™ PROGRAMMING GURUS
"Java Crash Course" contains a multitude of tips and tricks, examples and exercises you can do to grow your Java programming skills to unprecedented levels. We chose the content of this book carefully...
"Java Crash Course" contains a multitude of tips and tricks, examples and exercises you can do to grow your Java programming skills to unprecedented levels. We chose the content of this book carefully...
Write any Java program logic with strategies, tips, and tricks Leverage advanced topics in Java collections to solve Java-related problems Understand and use objects, classes, methods, and functions ...
英文经典原著 Java Reflection in Action Java Reflection in Action is unique in presenting a clear account of all the cool things you can do with reflection, and...author of Concurrent Programming in Java
Writing concurrent and parallel programming applications is an integral skill for any Java programmer. Java 9 comes with a host of fantastic features, including significant performance improvements ...
- **《Java Tips and Tricks》**:该书通过一系列的小贴士和技术要点帮助读者解决常见问题,并掌握一些高效编程的方法。 - **O'Reilly 出版的《Java I/O》**:深入介绍了 Java 输入输出流的概念和使用方法,对于理解...
sometimes perplexing programming techniques along with enough background to understand how to extend and vary them. This book overcomes reflection’s reputation as a mysterious and esoteric philo- ...
Also, Extreme Programming (XP), Agile Model Driven Development (AMDD) and refactoring are methods that can expedite the software development projects by reducing the amount of up front requirements ...
Also, Extreme Programming (XP), Agile Model Driven Development (AMDD) and refactoring are methods that can expedite the software development projects by reducing the amount of up front requirements ...
This step-by-step guide has examples on every page and is filled with bonus tips and tricks to make your app stand out. If you follow this guide you will have a completed app in as little as one day. ...
Groovy in Action is a comprehensive guide to Groovy programming, introducing Java developers to the new dynamic features that Groovy provides. To bring you Groovy in Action, Manning again went to the...
并且有一本《Tricks of the Windows Game Programming Gurus》英文(或者中文)书籍正在阅读。 说明:当看到André Lamothe大师所著游戏编程书籍时非常兴奋。本人在学习《Tricks of the Windows Game Programming ...
Author Rod Stephens is a well-known programming authority and has written more than 25 programming books covering C#, Java, VB, and other languages. ☆ 出版信息:☆ [作者信息] Rod Stephens [出版...
This book is for anyone who wants to learn computer programming and knows absolutely nothing about it. Of course, if you are wondering whether this book is going to teach you how to create amazing ...
Author Rod Stephens is a well-known programming authority and has written more than 25 programming books covering C#, Java, VB, and other languages. His books have sold more than 60,000 copies in ...