自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 servlet查询所有消息"List<Message>",并跳转到页面"messageList.jsp"进行显示

@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { MessageDao messageDao = new MessageDaoImpl(); try {

2014-07-30 20:06:56 1208

原创 HttpURLConnection获取网络图片

public class HttpURLConnectionTest { public static void main(String[] args) throws IOException { URL url = new URL("http://l-qta1.h.dev.cn6.qunar.com:9800/homework"); HttpURLConnec

2014-07-28 23:39:02 761

转载 guava Function

http://vipcowrie.iteye.com/blog/1525820

2014-07-28 14:15:09 423

原创 guava LineProcessor

public class Test { @org.junit.Test public void lineProcessTest() throws IOException { File file = new File(Test.class.getResource("/a.txt").getFile()); ArrayList list = (Array

2014-07-25 20:54:36 1427

原创 java硬编码

1. 注意到了“\n”的硬编码问题,使用 System.getProperty("line.separator") 代替,增加平台扩展性。

2014-07-24 10:23:28 2823

原创 序列化和反序列化的例子 程序中新建文件的操作

public class Serialization { Logger logger = LoggerFactory.getLogger(Serialization.class); String filePath = "serialization/"; File folder = new File(filePath); public static void ma

2014-07-23 07:43:40 422

原创 空格处理

Iterable parts = Splitter.on(',').trimResults(CharMatcher.anyOf(" ")).split(hotelInfo);

2014-07-22 18:16:03 728

原创 line.separator

在进行文件处理时,要经常对文件中的每一行进行处理,处理完一行将结果输出到BufferedWriter,此时还要输出一个换行符。Linux下换行符号可以用"\n"来表示,但在Windows下是不可以的,Windows用的是"\r\n"。为了让自己写的程序具有比较好的一致性,java其实提供了统一的特殊符号。对于换行符号可以System.getProperty("line.separator")来

2014-07-22 14:50:01 3295

原创 常用idea快捷键

Ctrl + Alt + V : introduce variable (never type the left hand side of an assignment again)Ctrl + Shift + Space : smart completion ( even two levels down since IntelliJ 8 )

2014-07-19 02:27:47 399

原创 java编译后class路径

public void getClassPath() { System.out.println(FileUtil.class.getResource("/test.txt")); System.out.println(FileUtil.class.getResource("/")); }

2014-07-17 17:32:57 600

原创 java基础培训

@Test public void testGetParams() throws IOException { FileUtil fileUtil = new FileUtil(); File paramFile = fileUtil.readFileFromInternet("http://fresh.qunar.com/sites/task3.proper

2014-07-17 16:53:44 437

原创 跨平台文件操作

1. 把文件放入resouces目录2.

2014-07-17 15:21:51 1016

原创 java异常的坑

1. URL url = null; try { url = new URL(fileUrl); } catch (IllegalArgumentException e) { logger.info("参数URL不合法",e); } catch (MalformedURLException e) {

2014-07-17 12:03:28 484

原创 几个java常量

System.getProperty("file.separator")); System.getProperty("path.separator"));  System.getProperty("line.separator"));

2014-07-17 11:25:55 544

原创 如果文件不存在,创建该文件

/** * @Title: writeFile * @Description: 写文件 * @param @param srcPath : 源文件路径 * @param @param targetPath : 目标文件路径 * @return void 返回类型 */

2014-07-16 20:22:09 714

原创 java读取网络文件

public class FileUtil { private Logger logger = (Logger) LoggerFactory.getLogger(FileUtil.class); public void readFileFromInternet(String fileUrl, String fileName) throws IOException {

2014-07-16 19:35:43 729

原创 java习题汇总

前提:Java源码中的注释是完整的,既有开头,又有结尾(1)如果要统计java源代码中的注释数目,每次读取一行,(2)一直到,在某一行中出现"//"或"/*"或"/**",若同时出现三个中的两个或者全部,以最前面的为注释开头;(3)然后接着逐行读取源码内容,忽略注释中的内容;(4)一直到,在某一行中出现与前面注释开头对应的注释结尾,若同时出现多个,以最后面的为注释结尾;(5)这

2014-07-15 11:05:12 1097

原创 查找一个目录下,所有文件中数字、字母(大小写不区分)、汉字、空格的个数、行数。

汉字在java中占两个字符(char).

2014-07-15 00:11:16 2351

原创 Map中按照value的大小进行排序

把Map中的数据按照value的大小进行排序并输出是

2014-07-10 16:48:43 5473

原创 TreeMap学习笔记(一)

package com.qunar.yuliang.test13;import com.google.common.base.Charsets;import com.google.common.io.Files;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import java.io.File;imp

2014-07-10 13:13:36 648

原创 String.split() 字符串分割

将以下每一行按照          hotelInfoParts[i] = lines.get(i).split("\\s+");

2014-07-10 11:20:21 719

原创 junit 笔记(一)

当我们写了多个测试类之后,可以将这些个类组织成一个

2014-07-09 23:53:02 444

转载 Junit assertThat

assertThat()常用的方法有:a)assertThat( n, allOf( greaterThan(1), lessThan(15) ) ); n满足allof()里的所有条件assertThat( n, anyOf( greaterThan(16), lessThan(8) ) );n满足anyOf()里的任意条件assertThat( n, anything() );

2014-07-09 16:29:02 421

原创 Guava CharMatcher

@Test public void testRemoveWhiteSpaceUsingRegexp() { String s = " first dfgdfgdsfas "; String expectedString = "firstdfgdfgdsfas"; String target = s.replaceAll(" +","")

2014-07-09 14:25:39 513

转载 json数据解析

var myObject = { "first": "John", "last": "Doe", "age": 39, "sex": "M", "salary": 70000, "registered": true, "interests": [ "Reading", "Mountain Biking", "Hacking" ], "favorites": {

2014-07-08 00:28:30 387

原创 Qunit学习(二)——dataset

dataset:qunit测试中一般要给数据库中预存一些数据以辅助测试,比如修改,删除等操作。这些数据以xml文件进行配置,以表名命名。我们以user.xml为例。

2014-07-03 11:32:34 749

原创 Qunit学习(一)

前提:引入必要的依赖1.配置qunit.properties()2.编写测试脚本(user.xml)3.配置service.xml4.配置Qunit测试入口,UserTest.java

2014-07-02 18:10:45 519

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除