Click here to Skip to main content
15,891,607 members
Home / Discussions / Java
   

Java

 
QuestionCannot access database Pin
tamour9-Jan-09 3:19
tamour9-Jan-09 3:19 
QuestionDeveloping a discussion forum using java? Pin
avvisaan8-Jan-09 4:59
avvisaan8-Jan-09 4:59 
QuestionPort address Translation Pin
bobbo886-Jan-09 5:16
bobbo886-Jan-09 5:16 
QuestionHelp Please (java only please) Pin
bobbo886-Jan-09 3:40
bobbo886-Jan-09 3:40 
AnswerRe: Help Please (java only please) Pin
tamour9-Jan-09 11:56
tamour9-Jan-09 11:56 
GeneralRe: Help Please (java only please) Pin
bobbo8812-Jan-09 4:04
bobbo8812-Jan-09 4:04 
GeneralRe: Help Please (java only please) Pin
tamour13-Jan-09 18:01
tamour13-Jan-09 18:01 
QuestionTwo PrintStream objects for the same file Pin
DV_Dikla4-Jan-09 19:37
DV_Dikla4-Jan-09 19:37 
Hi Everybody,

I have a file which I use for writing some output during the run of the program. I also want this file to hold the error stream, in case of a problem.

I created the following code, to check what happen:

PrintStream psMyFile = new PrintStream("myFile.txt");

FileOutputStream fos = new FileOutputStream("myFile.txt", true);
PrintStream psErrorStream = new PrintStream(fos);
System.setErr(psErrorStream);

for (int i=0; i<5; i++)
	psMyFile.println("line " + i);

System.err.println("This is an error 1");
psMyFile.println("after the error");
System.err.println("This is an error 2");
psMyFile.println("finished");


The content of "myFile.txt" afterward are:
line 0
line 1
line 2
line 3
line 4
after the error
finished
an error 2


As you can see, some of the errorStream text was lost. Also, I would expect that the last line will appear before the line before it. D'Oh! | :doh:

Why does that happen? Is there a way to synchronize the writing, so that nothing will get lost?

TIA!
Dikla
Questionhierarchical data in a true tree format Pin
Sambou52363-Jan-09 20:40
Sambou52363-Jan-09 20:40 
QuestionNetwork programming help!!!!!!! Pin
romance12-Jan-09 7:55
romance12-Jan-09 7:55 
Questionhow can I parse a queary into parts to write a search parsing Pin
D V kirankumar31-Dec-08 0:26
D V kirankumar31-Dec-08 0:26 
QuestionHelp in java subclassinng, inheritance Pin
homiee125-Dec-08 0:41
homiee125-Dec-08 0:41 
QuestionRe: Help in java subclassinng, inheritance Pin
code_var26-Dec-08 3:10
code_var26-Dec-08 3:10 
Questionhow to pass initialization parameters in servlets Pin
shofia.m24-Dec-08 4:07
shofia.m24-Dec-08 4:07 
Questionhow to connect servlet with ms sql2000 Pin
shofia.m24-Dec-08 4:03
shofia.m24-Dec-08 4:03 
QuestionKeyListener - keyPressed delay Pin
max2929723-Dec-08 18:33
max2929723-Dec-08 18:33 
AnswerRe: KeyListener - keyPressed delay Pin
max2929725-Dec-08 17:33
max2929725-Dec-08 17:33 
Questionjava nlp project Pin
navasan22-Dec-08 21:03
navasan22-Dec-08 21:03 
AnswerRe: java nlp project Pin
toxcct22-Dec-08 21:36
toxcct22-Dec-08 21:36 
AnswerRe: java nlp project Pin
navasan22-Dec-08 22:30
navasan22-Dec-08 22:30 
Questioncohen sutherland implementation Pin
427748021-Dec-08 12:57
427748021-Dec-08 12:57 
Questionhelp me!...ASAP Pin
ericson045019-Dec-08 23:32
ericson045019-Dec-08 23:32 
AnswerRe: help me!...ASAP Pin
toxcct21-Dec-08 21:59
toxcct21-Dec-08 21:59 
GeneralRe: help me!...ASAP [modified] Pin
code_var26-Dec-08 3:55
code_var26-Dec-08 3:55 
GeneralRe: help me!...ASAP Pin
ericson045026-Dec-08 8:01
ericson045026-Dec-08 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.