
java技巧
kaqi072821
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Arrays.sort(Comparator) 巧用
java 代码 /** * <p> * This method simply orders the ranked query result by date. * </p> * * @param result ranked result to be ordered * * ...2007-06-13 14:04:10 · 1484 阅读 · 0 评论 -
java读取文件的路径如何找的
is = getClass().getClassLoader().getResourceAsStream(roleFile);这个是从classpath下找。is =getClass().getResourceAsStream(roleFile);这个是跟所给的class在同一级的目录下找。...2009-06-04 13:58:35 · 200 阅读 · 0 评论 -
JAAS
http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/index.jsp?topic=/rzaha/api.htm Java Authentication and Authorization Service (JAAS)1.0 The Java™ Authentication and Authorization Se...原创 2009-06-09 11:10:41 · 174 阅读 · 0 评论 -
ant 用户手册
http://ant.apache.org/manual/index.html原创 2009-01-07 11:04:17 · 120 阅读 · 0 评论 -
java Serialization
http://www.blogjava.net/orangelizq/archive/2008/09/05/227169.html Serializing Objects Into Databasehttp://www.roseindia.net/javatutorials/serializing_objects_into_database.shtml 1....原创 2009-06-29 11:09:24 · 107 阅读 · 0 评论 -
将一个文件由gbk 转成 utf-8
public void transform(String fileName) { try { String line_separator = System.getProperty("line.separator"); FileInputStream fis; fis = new FileInputStream(fileName); StringBuffer ...原创 2010-08-11 21:02:44 · 134 阅读 · 0 评论 -
Will android (java) UUID.randomUUID() return repeated UUIDs?
Theoretically, I don't think this method will return repeated UUIDs, even from different devices.Let's check the documentation of android: http://developer.android.com/reference/java/util/UUID.html....原创 2013-11-19 06:11:35 · 159 阅读 · 0 评论 -
java读取文件内容
//将要读的文件文件放在resources/xml/目录下, resources设置成source folder public String getContent(String modelFileName) { InputStream fileStream = getClass().getClassLoader().getResourceAsStream("xm...原创 2013-11-19 15:37:44 · 139 阅读 · 0 评论 -
Tomcat 在启动时开启调试
很容量找到怎么在tomcat中远程调试的文章。如http://stackoverflow.com/questions/6733849/remote-debugging-in-intellij-tomcat 但是这种调试只能在tomcat启动完成之后才能开启。但是我们有时想调试tomcat启动时用到的代码,如一应用的初始化代码。其实很简单。 <jvmarg line="-...原创 2017-03-31 11:47:00 · 381 阅读 · 0 评论 -
Easiest way to read write files in java 8
Path path = Paths.get(getClass().getClassLoader() .getResource("fileTest.txt").toURI()); //relative to the classString content = new String(Files.readAllBytes(path));try (Stream<Stri...原创 2017-10-25 15:46:36 · 184 阅读 · 0 评论 -
memory management in java
https://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java原创 2017-12-07 15:25:06 · 282 阅读 · 0 评论 -
要到另一个目录下运行ant, .bat文件中调用ant
<ant antfile="build.xml" target="test" dir="projects/project1"/> 用以上命令,会执行"projects/project1"下面的ant脚本,但是运行目录会是当然所在的目录".",也就是说ant运行中如果用到相对文件路径会是相对于当前路径而不是build.xml所在路径。 如果需要相对于build.xml2009-05-21 09:50:53 · 328 阅读 · 0 评论 -
Thread join() 用法
Thread[] cThreads = new Thread[complexRequestNum]; Thread[] sThreads = new Thread[complexRequestNum]; for (int i = 0; i < complexRequestNum; i++) { cThreads[i] = new Thr...2008-11-11 20:36:13 · 190 阅读 · 0 评论 -
一个生成json字符串的类
public class UserProjWorkloadQueryTreeNodeUtil { @SuppressWarnings("unchecked") public static String getJsonString(List<UserProjWorkloadQueryTreeNode> list) { if (list == nu...2009-04-16 13:08:51 · 137 阅读 · 0 评论 -
如何访问一个对象的私有变量
如何访问一个对象的私有变量Filed under: 项目日志 — zhangruimin @ 22:12 Edit This为什么要访问一个对象的私有变量呢?在单元测试时可能要查看私有变量是否被正确赋值,也有可能单元测试时要用到一个对象让它的一个私有变量为特定值,但又没有set方法。私有变量不能通过对象直接访问,但是并不是说一个类的私有变量就不能访问。有一个绝招就是利用反射机制。/**...2007-06-13 19:28:47 · 485 阅读 · 0 评论 -
Introduction to the Java Persistence API(java tutorial link)
http://java.sun.com/javaee/5/docs/tutorial/doc/?wp406143&PersistenceIntro.html#wp784602007-06-15 09:48:03 · 95 阅读 · 0 评论 -
从文件读写字符串的标准格式
java 代码 /** * Reads a text file to a String. The result String includes a '\n' after * each line in the file. * * @param fileName the name of the file to read * ...2007-06-30 13:56:23 · 246 阅读 · 0 评论 -
利用java.util.Properties从properties文件读入properties
java 代码 // reads the properties from the property file Properties props = new Properties(); try { props.load(new FileInputStream(PROPERTIES_FILE)); ...2007-07-02 18:29:36 · 153 阅读 · 0 评论 -
由xml和Document的标准操作
xml 到Documetnjava 代码 public XmlFileConfigurationStrategy(File xmlSource//TODO validate should be used throws ConfigurationException { Helper.checkObject(xmlSource, "xmlSou...2007-07-09 22:49:35 · 107 阅读 · 0 评论 -
使用java.util.Calendar返回间隔天数
java 代码 ** * Calculates the number of days between two calendar days in a manner * which is independent of the Calendar type used. * * @param d1 The first date. ...2007-07-29 13:32:27 · 343 阅读 · 0 评论 -
StringBuffer VS StringBuilder
现在看了,知道了,太简单了,其实说白了,StringBuffer 和 StringBuilder 的区别就如同 HashTable 和 HashMap 的区别;就如同 ArrayList 和 Vector 的区别。是的,只是区别在同步与非同步上、线程安全与不安全,同时由此影响的单线程环境时的性能上。 StringBuffer 和 StringBuilder 在提供给外部方法是一样...2007-09-08 23:05:19 · 148 阅读 · 0 评论 -
Form-Letter Programming
Form-Letter Programming VS MessageFormat今天阅读<<编程珠玑>>时发现讲到了Form-Letter Programming,其实这种思想在jdbc,hibernate等地方都有用到。即在字符串中给待替换的参数起个名字,之后将这个名字替换成相应的参数。正好前几天在阅读代码时看到人家用MessageFormat。这个类完全是Form...2007-09-10 20:54:18 · 111 阅读 · 0 评论 -
利用Serialization实现对象深拷贝
java 代码 private PersonAggregateData copyAggregate(PersonAggregateData original) throws EventsPersonManagementException { ByteArrayOutputStream outputBytes = new ByteArrayO...2007-10-25 22:54:06 · 121 阅读 · 0 评论 -
运用Calendar进行java日期处理
取得时间点所在的日的起始时间和结束时间(From Quartz): protected java.util.Calendar getStartOfDayJavaCalendar(long timeInMillis) { java.util.Calendar startOfDay = createJavaCalendar(timeInMillis); st...2009-03-21 16:58:22 · 153 阅读 · 0 评论 -
IntelliJ IDEA Live Templates for Unit Testing
http://vansande.org/2015/03/26/intellij_idea_live_templates_for_unit_testing/原创 2017-12-12 17:29:59 · 266 阅读 · 0 评论