Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use "tab space" while writing in text file

 SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy_HHmmSS");  String strCurrDate = formatter.format(new java.util.Date());  String strfileNm = "Cust_Advice_" + strCurrDate + ".txt";  String strFileGenLoc = strFileLocation + "/" + strfileNm;  String strQuery="select name, age, data from basetable";  try {       stmt = conn.createStatement();      System.out.println("Query is -> " + strQuery);      rs = stmt.executeQuery(strQuery);       File f = new File(strFileGenLoc);      OutputStream os = (OutputStream)new FileOutputStream(f);      String encoding = "UTF8";      OutputStreamWriter osw = new OutputStreamWriter(os, encoding);      BufferedWriter bw = new BufferedWriter(osw);       while (rs.next() ) {           bw.write(rs.getString(1)==null? "":rs.getString(1));          bw.write("  ");          bw.write(rs.getString(2)==null? "":rs.getString(2));          bw.write("  ");       }      bw.flush();      bw.close();  } catch (Exception e) {      System.out.println(          "Exception occured while getting resultset by the query");      e.printStackTrace();  } finally {      try {          if (conn != null) {              System.out.println("Closing the connection" + conn);              conn.close();          }      } catch (SQLException e) {          System.out.println(              "Exception occured while closing the connection");          e.printStackTrace();       }     }          return objArrayListValue;   } 

i need "one tab space" in between each column(while writing to text file). like

   manu 25 data1    manc 35 data3 

in my code i use bw.write(" ") for creating space between each column. how to use "one tab space" in that place instead of giving "space".

like image 573
Manu Avatar asked Apr 06 '10 13:04

Manu


People also ask

What does \t do in HTML?

It is equivalent to the tab character as such. Thus, from the HTML viewpoint, there is no need to “escape” it using the character reference; but you may do so e.g. if your editing program does not let you enter the character conveniently.

How do you add tab spacing in HTML?

Type   to add a single space. Type   to add 2 spaces. Type   to add 4 spaces.

How do I find a tab character in a text file?

To "find" a Tab, highlight a Tab, copy it (ctrl+C), then paste it into the "find" box: ctrl+v. (f) Use FORMAT= or MFORMS= to pick up every other column.

How do you add a tab space in Python?

In Python strings, the backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters: "\t" is a tab, "\n" is a newline, and "\r" is a carriage return. Conversely, prefixing a special character with "\" turns it into an ordinary character.


1 Answers

You can use \t to create a tab in a file.

like image 164
tmeisenh Avatar answered Sep 19 '22 21:09

tmeisenh