Skip to main content

Posts

Showing posts with the label java

Replacing $ in a String in Java

I faced an issue in my project recently where we read a password for an admin user first from a file which has a dummy or wrong password written in it. Then I read the password from database and replace the dummy password with the real password that I get from Database. So the code was something very simple like this (this is actually different from originalk). String myXmlDoc = readALargeXmlAsString(); String realPassword = readFromDatabase(); String password = myXmlDoc.replaceAll("dummyPassword", realPassword); All on a sudden we found that this replacement started failing after the password of that admin user was changed recently. Here is the exception log. Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendReplacement(Matcher.java:706) at java.util.regex.Matcher.replaceAll(Matcher.java:806) at java.lang.String.replaceAll(String.java:2000) at com.salesforce.test.StringReplaceTest.mai...

My Thoughts On SCJP Java 6

Recently I have been thinking about the industry standard technology certifications, particularly around Java/JEE technologies. I am not exactly sure how valuable the technology certifications are when you are already an experienced veteran in the industry. But I can guess that it will give an impression to your upper management to accommodate you for the next level (higher level than where you are) or while switching jobs will justify you to apply for a higher title than you are in now. Once I am successfully done with my hiking in Half Dome of Yosemite a few weeks later, I will be focusing on the Sun Certified Java Programmer (SCJP) exam on Java 6 platform. Although in my current project we use Java 5, we will be moving to Java 6 sooner or later as some other teams as well as the core platform team in Salesforce uses Java 6. Also it makes sense to get certified on the latest version of Java so that it can around your neck for a longer period of time in your career. I already talke...