Simplifying Java Software Development: How to Count the Number of Words in a String using Java (one-liner)June 18th, 2005 Java is a language of choice for millions of developers worldwide. In a series of articles I will show simple tips and techniques which make Java extremely powerful and yet simple to use.
Java Quiz: Why StringBuilder Should be Used Instead of StringBuffer?August 23rd, 2008 First tell me what is the best way to concatenate large number of String objects? Is it a + b?
Most Java developers know not to use a + b (+ operator) because of huge performance problems, they use StringBuffer instead. In fact I did some tests in the past which confirms this folklore.
How To Add Trim Functionality To Javascript StringAugust 12th, 2007 Trim is a useful function available in languages like Java & PHP which removes the leading and traling whitespace(s) from a String. Unfortunately Javascript doesn't natively provide trim functionality to the String object.
How To Compare Strings With == in JavaFebruary 25th, 2006 Almost every java developer finds one fine morning that he cannot compare String with "==" as he has been doing with int or char. Then either he finds out or someone kindly tells him that objects cannot be compared with "==".
Java Coding: How To Find Number of Characters in a String (!= String.length())November 7th, 2005 Length of string can be interpreted variously -
number of chars in the string
number of characters in the string
number of bytes in the string
String.length() gives you the number of chars in the string accurately. However a char is not necessarily a complete character.
Java Software Programming Examples For Beginners / Interview: How To Swap Integer (and String) Variables Without Using a Temporary VariableOctober 29th, 2005 A Simple Programming Question for Beginners
Java Program: Compare two text filesApril 29th, 2009 Today while managing the comments, I got a request of this sort. HI,
I have a small question in java.
JDK1.5 - More painful bugs aka Enumeration-Woes: Solved!August 29th, 2004 Current Status: Solved
Defect:
When more than one annotation type files are compiled in javac(any of the ways like *.java or @srclist or FileName1.java FileName2.java)
then it emits and error message that it cannot find symbol for statically imported Enums. However statically importing one level up and de-referencing works.
Understanding Varargs in Java: 2 Minute Guide For Non-DummiesApril 30th, 2006 Varargs allows variable number of arguments in methods and constructors. Let's start with a simple example.
Java EE 5 is Not Your Father's J2EEApril 10th, 2006 Java Platform Enterprise Edition (Java EE, formerly referred to as J2EE) Version 5 has arrived. Its streamlined features offer added convenience, improved performance, and reduced development time, all of which enable developers to bring products to market faster.
HSQLDB Tip: Case Insensitive LIKE Query in HSQLDB RDBMS & Space Crunched String ComparisonJuly 21st, 2007 I previously discussed how to extend HSQLDB relational database with simple Java functions. The example there actually implements case insensitive like query functionality for HSQLDB.
Java Software: 1-Line Sort & Uniq UtilityOctober 18th, 2005 I had to sort and uniq (create a unique set of strings) a large list with lots of duplicate. My options were to write it in Java or download cygwin and run: cat file | sort | uniq > result
Cygwin download never works for me.
Guide To Simplified Java Logging using Java Core APIJanuary 17th, 2006 Java comes in with a handy logging package (java.util.logging) which eliminates the need to use external logging packages like Log4J. However it still requires some configuration which makes it cumbersome and repetitive to include in every class.
Tip: How To Extend HSQLDB RDBMS With Java FunctionsJuly 17th, 2007 HSQLDB is an unique high performing, high quality Java based relational database which can be very easily extended with simple Java static functions. Here we will see how you can easily extend the database capability with a real-life example.
Java Tip: Basic Authentication with HttpURLConnectionJuly 6th, 2007 Java provides a super simple, yet hidden from plain view, way to do basic authentication of HttpURLConnection / URLConnection. Before making a connection add the following lines of code:
final String login ="...";
final String password ="...";
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication (login, password.toCharArray());
}
});
This sets your default Authenticator which is called whenever authentication is required for any URLConnection.
July 20th, 2007 at 1:07 pm
Since “\r” is first, “\r\n” is never found.
July 21st, 2007 at 1:54 am
Which is why the \r and \n of a “\r\n” are treated separately and an empty line is assumed in between them.
November 27th, 2007 at 8:43 am
Hi
Can any one provide the solution for this
String a = “10.00″;
String result[] = a.split(”.”);
for(String value[] : result)
{
System.out.printl(value[0].toString());
}
But in this case the output is not reaching the for loop
Can anyone provide the solution for this.
January 22nd, 2008 at 12:54 am
Answer to #3
To split a string around periods (.), use …
a.split("\\.")December 23rd, 2008 at 12:06 pm
can anyone please tell me how to split the string
String s =”$KL8G4391,061208,1130002,17266724N,0765423E,002,273#”;
without the $ or the # sign appearing.
June 20th, 2009 at 6:56 pm
i have a textarea where a user can enter free flow text.I want to seperate out lines/occurences in my java class based on the below conditions:
Unless the user presses the enter key i want to get substrings(texts) of 15 characters each or else whenever the user presses enter i want to seperate that part out and start again counting till 15 to get a new splittted substring till i reach the end of the free flow text/string.
Eg,
If user enters:
Heloo i want
enter key to be caught.
So i want this text to be seperated into the below substrings:
1. Hello i want(assuming the user pressed enter key at this point)
2. enter key to be(as the limit is 15)
3. caught