Related Examples
  1. printWriter write5 Example
  2. printWriter write4 Example
  3. printWriter write3 Example
  4. printWriter write2 Example
  5. printWriter write1 Example
  6. printWriter print6 Example
  7. printWriter print5 Example
  8. printWriter print4 Example
  9. printWriter print3 Example
  10. printWriter print2 Example
  11. printWriter print1 Example
  12. printWriter format1 Example
  13. printWriter format2 Example
  14. printWriter checkError Example
  15. printWriter append3 Example
  16. printWriter append2 Example
  17. printWriter append1 Example
  18. printWriter rename Example
  19. PrintWriter printf Example
  20. PrintWriter printf Example
  21. PrintWriter write Example
  22. PrintWriter write Example
  23. PrintWriter write Example
  24. PrintWriter write Example
  25. PrintWriter write Example
  26. PrintWriter println Example
  27. PrintWriter println Example
  28. PrintWriter println Example
  29. PrintWriter println Example
  30. PrintWriter println Example
  31. PrintWriter println Example
  32. PrintWriter println Example
  33. PrintWriter println Example
  34. PrintWriter println Example
  35. PrintWriter format Example
  36. PrintWriter format Example
  37. PrintWriter println Example
  38. PrintWriter print Example
  39. PrintWriter print Example
  40. PrintWriter print Example
  41. PrintWriter print Example
  42. PrintWriter print Example
  43. PrintWriter print Example
  44. PrintWriter print Example
  45. PrintWriter print Example
  46. PrintWriter print Example
  47. PrintWriter flush Example
  48. PrintWriter close Example
  49. PrintWriter checkError Example
  50. PrintWriter append Example
  51. PrintWriter append Example
  52. PrintWriter append Example
  53. Java Class PrintWriter, Java PrintWriter Methods, Java PrintWriter Functions,PrintWriter Examples Java

View All Examples
 

printWriter write2 Example

printWriter class write example. This example shows you how to use write method.


PrintWriter class write example.write() method in the program returns sequence of char values from the char array as per defined indexes.char array variable is passed in to the method constructor and the array value up to indexes defined is writed into the abstract pathname file.

Here is the code:-
/**
 * @Program uses write method to generate sequence 
 * of char values as per defined indexes and to write to character 
 * output stream of specified abstract pathname file.
 * Write2.java 
 * Author:-RoseIndia Team
 * Date:-7-july-2008
 */

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

public class Write2 {
  public static void main(String args[]) throws IOException {
    File witches = new File("c:\tanushree.doc");
    PrintWriter out = new PrintWriter(witches);
    char[] array0 = 'O''c''o''p''s''O' }, array1 = 's''t',
        'i''l''l''0' }, array2 = 'e''s''c''a''p''e',
        'd''0' };
    String str0 = new String("chasing"), str1 = "Thieves";

    out.write(str1);
    out.print(" ");
    out.write(array2, 07);

    out.println("");

    out.write(array0, 14);
    out.print(" ");
    out.write(array1, 05);
    out.print(" ");
    out.write(str0);

    out.flush();
  }
}

Output of the program:-
Method generates results in the file specified and not on program output console.
Thieves escaped
cops still chasing

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US