Hi all,
i am new to java, i am doing a grid computing project,
anyone related to the fields please reply me. so that i can discuss my problems with u.

regards

I can try and help you. If not, I can direct you to somewhere help can be found. What's the problem?

hi,
i have following problems in the code.
i want to write console result in a seperate file
the code is

FileOutputStream out; // declare a file output object
           PrintStream p; // declare a print stream object

           try
           {
                   // Create a new file output stream
                   // connected to "myfile.txt"
                   out = new FileOutputStream("myfile.txt");

                   // Connect print stream to the output stream
                   p = new PrintStream( out );
	
                   p.println ("This is written to a file");

                   p.close();
           }
           catch (Exception e)
           {
                   System.err.println ("Error writing to file");
           }

       }
       catch (Exception e)
       {
           e.printStackTrace();
           System.out.println("Unwanted errors happen");
       }
   }

but it just prints " This is written to a file "
what should i write here to print my programs output?

secondly i am applying timer to do some task repeatedly. i ant the timer to hold after its expires means if a want it to expire after every 2 seconds but when it expires i want it to hold to do some work then to start it again so that it again expire after 2 seconds.
hope i'll get a positive response from u
thanx for being helpful to me
regards

Edited 6 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

p.println ("This is written to a file");

That is what is written to the file. I can't understand what is the problem. It writes whatever you want it to write. If you want something else written then put whatever you want written in that code:

p.println ("This is written to a file");
p.println ("and this");
p.println ("and this");
p.println ("and this");
p.println ("and this");

Also you have posted what you want written. Whatever results you get just put them as parameter at the println method

Yeah, Sana. javaAddict pretty much said it all. This looks like a piece of a larger project so maybe the difficulty you're having is somewhere else; are you sure this was the question you meant to ask? Are you getting any error messages?

About the timer… I'm sure there are some methods listed in the Java API that will allow you to pause some event for a period of time. Check it out. You will have to know the package and class your working with is though, which you could just google. If you don't find something that does exactly what you want, get creative and mix and match some of the methods available. Good luck!

This article has been dead for over six months. Start a new discussion instead.