Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tablated Data in output file 1

Status
Not open for further replies.

Funkymatt

Programmer
Aug 27, 2002
101
US
How do i output a tab following:
out.write("this is a test");
 
The new line was pretty easy and I feel dumb for asking:

BufferedWriter out = new BufferedWriter(new FileWriter(fileName));

//The while the vector is not empty keep processing
while (intCounter < vecList.size())
temp = (FundsTxnMaster)vecList.get(intCounter);
//temp.printAll();
out.write(&quot;this is a test&quot;);
//would like a tab here
out.write(&quot;this is a test&quot;);
out.newLine();
intCounter++; //Increment the counter
}
 
tabs, carriage returns, backslash and quotes are 'Escape Characters'
You can't write these in your code between &quot; &quot; like other characters. Instead you have to use Escape Sequences.
These sequences begin with a backslash

System.out.print(&quot;this\tis a\ntest&quot;);

This example will print:

this is a
test

For more info:

 
Thanks Stijn147. :)

I guess my only other question would be what is the difference between using:

out.write(&quot;this is a\ntest&quot;);

AND
out.write(&quot;this is a&quot;);
out.newLine();
out.write(&quot;test&quot;);

Is (out.newLine(); == out.write(&quot;\n&quot;);) ?
 
This is what I find in the API specification of BufferedWriter:


public void newLine() throws IOException

Write a line separator. The line separator string is defined by the system property line.separator, and is not necessarily a single newline ('\n') character.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top