printWriter append3 Example
printWriter class append example. This example shows you how to use append method.
PrintWriter class append example.method results part of the char sequence as per defined indexes.class FileOutputStream used as parameter inside the constructor of PrintWriter object is writing data to the abstract pathname associated file.
Here is the code:-
/**
* @Program uses append method to generate subsequence of char
* values as per mentioned indexes.
* pathname file;
* Append3.java
* Author:-RoseIndia Team
* Date:-5-july-2008
*/
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.File;
public class Append3 {
public static void main(String args[]) throws IOException {
File multi = new File("c:\Desktop\sadhna.txt");
System.out.println(multi.createNewFile());
PrintWriter dimensional = new PrintWriter(new FileOutputStream(multi));
char[] array = { '#', 'm', 'i', 'n', 'd', '#' };
char[] array1 = { '#', 'o', 'v', 'e', 'r', '#' };
char[] array2 = { '#', 'm', 'a', 't', 't', 'e', 'r', '#' };
String knight_mare = new String(array);
String heaven = new String(array1);
String hell = new String(array2);
dimensional.append(knight_mare, 1, 5);
dimensional.print(" ");
dimensional.append(heaven, 1, 5);
dimensional.print(" ");
dimensional.append(hell, 1, 7);
dimensional.close();
}
} |
Output of the program:-
Result is generated on the specified abstract pathname file and not on the console
mind over matter |
|