hello guys, i need a lil guidance here
i am trying to save the output from my "SThreads" results to a txt file without deleting the
previously stored data, i jst want to keep adding to the file..any suggestions that will help are appreciated..
heres the code i have done so far,
import java.io.*;
public class SThread extends Thread {
private int countDown = 5;
private int threadNumber;
private static int threadCount = 0;
public SThread() {
threadNumber = ++threadCount;
System.out.println("Making " + threadNumber);
}
public void run() {
while(true) {
System.out.println("Thread " +
threadNumber + "(" + countDown + ")");
if(--countDown == 0) return;
}
}
public static void main(String[] args) {
for(int i = 0; i < 5; i++)
new SThread().start();
System.out.println("All Threads Started");
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String lineFromInput = in.readLine();
PrintWriter out = new PrintWriter(new FileWriter("d:output.txt"));\\ file to output or save to
out.println(lineFromInput);
out.close();
}
catch(IOException e)
{
System.out.println("Error during reading/writing");
}
}
}
thnx for your time..
tc