Hi all, does anyone know of a good online resource that simply and definitevly explains how to use the string formatter method...?
I need to write a series of "records" into a set ascii text files. I need to "delimit" each "record" with a cr-lf sequence in a windows 2008 server environment.
Therefore I'm trying to figure out how to add a \r\n character string at the end of each "record". I tried a "record_string.append(CR) and LF" ; but it didn't work.
Hello Guy, I noticed that you asked the same question on StackOverflow, where I also posted an answer. As Rob says, using \r\n should work, and you can find a list of escape sequences in section 3.10.6 of the Java Language Specification.
When you're using for example a StringBuilder to build a record, you can just append \r\n to it:
Start in the Java™ Tutorials, and look at the sections marked "formatting" or similar. Look up the java.util.Formatter class, and the String#format method takes the same arguments as System.out.printf and Formatter#format.