Search code examples
javaprintwriterprintln

JAVA PrintWriter println method


I am trying to use the println method of PrintWriter to write the following to a single line:

100,iPod,Book,100

The types of the above are: Int, String, String, double,respectively.

Can someone please tell me how this can be accomplished? Thanks.


Solution

  • I think this is what you mean:

    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    int i1= 100;
    String str2="ipod";
    String str3="book";
    double d4=100;
    pw.println(i1+","+str2+","+str3+","+d4);