writing a string into a text file
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class Main {
public static void main(String[] args) {
String result;
result = "testtest";
try {
PrintStream ps = new PrintStream(new FileOutputStream("D:\\test\\output.txt"));
ps.println(result);
ps.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
I have a couple of string to write into text file
- for example--
String test1="aaa";
String test2="bbbb";
String test3="c";
String test4="dd";
condition to write into text file....
test1 has to write between 1 - 5 position.
test2 has to write between 6 - 15 postition.
test3 has to write between 16 - 10 position.
test4 has to write between 11 - 15 position.
-
how can i write those strings into a certain position?
how can i write those strings for 3 times in a text file?(make 3 rows)

