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

Java

 
GeneralRe: Annotation Processor in Eclipse Pin
Skippums10-Nov-11 10:51
Skippums10-Nov-11 10:51 
GeneralRe: Annotation Processor in Eclipse Pin
Nagy Vilmos10-Nov-11 10:54
professionalNagy Vilmos10-Nov-11 10:54 
AnswerRe: Annotation Processor in Eclipse Pin
Skippums10-Nov-11 12:52
Skippums10-Nov-11 12:52 
GeneralCode Analysis Pin
gamer11278-Nov-11 6:59
gamer11278-Nov-11 6:59 
GeneralRe: Code Analysis Pin
Nagy Vilmos8-Nov-11 7:06
professionalNagy Vilmos8-Nov-11 7:06 
Questionstring compare java problem Pin
Jim Crafton8-Nov-11 3:51
Jim Crafton8-Nov-11 3:51 
AnswerRe: string compare java problem Pin
Nagy Vilmos8-Nov-11 4:23
professionalNagy Vilmos8-Nov-11 4:23 
GeneralRe: string compare java problem Pin
Jim Crafton8-Nov-11 5:32
Jim Crafton8-Nov-11 5:32 
public static synchronized void logTrace( String s, boolean outputToStdOut ){
	LoggingPolicy policy = ....
	
	String fname = policy.getLogFileName();
	
	try {
		if ( null == Logging.instance().logOutput) {				
			Logging.instance().logOutput = new FileWriter( fname, true );
			Logging.instance().setCurrentLogName(fname);
		}
		else {
			
			String current = Logging.instance().getCurrentLogName();
			if ( !current.equals(fname) ) {
				Logging.instance().logOutput.close();
				Logging.instance().logOutput = null;
				Logging.instance().logOutput = new FileWriter( fname, true );
				Logging.instance().setCurrentLogName(fname);
			}
		}
		Logging.instance().logOutput.write( outStr + "\r\n" );
		Logging.instance().logOutput.flush();
		
	}
	catch( Exception e ) {
		e.printStackTrace();		
	}
}



Something like the above. took out some extra crap, but that's the basic idea. getCurrentLogName()/setCurrentLogName() set the log filename for the singleton. logOutput is var for the FileWriter.

In the past I create a new FileWriter every time I came in here, and while that did work, it also was a big enough performance hit that we started to notice it for certain programs and slowed things down a bit. So I tried to get clever... Roll eyes | :rolleyes:

¡El diablo está en mis pantalones! ¡Mire, mire!
SELECT * FROM User WHERE Clue > 0
0 rows returned

Save an Orange - Use the VCF!
Personal 3D projects
Just Say No to Web 2 Point Blow


GeneralRe: string compare java problem Pin
Nagy Vilmos8-Nov-11 5:47
professionalNagy Vilmos8-Nov-11 5:47 
GeneralRe: string compare java problem Pin
Jim Crafton8-Nov-11 5:56
Jim Crafton8-Nov-11 5:56 
GeneralRe: string compare java problem Pin
Richard MacCutchan8-Nov-11 9:22
mveRichard MacCutchan8-Nov-11 9:22 
GeneralRe: string compare java problem Pin
Nagy Vilmos8-Nov-11 10:03
professionalNagy Vilmos8-Nov-11 10:03 
GeneralRe: string compare java problem Pin
Richard MacCutchan8-Nov-11 10:06
mveRichard MacCutchan8-Nov-11 10:06 
GeneralRe: string compare java problem Pin
anshul.zunke26-Nov-11 17:26
anshul.zunke26-Nov-11 17:26 
AnswerRe: string compare java problem Pin
jschell8-Nov-11 10:10
jschell8-Nov-11 10:10 
GeneralRe: string compare java problem Pin
TorstenH.8-Nov-11 19:07
TorstenH.8-Nov-11 19:07 
GeneralRe: string compare java problem Pin
anshul.zunke26-Nov-11 17:28
anshul.zunke26-Nov-11 17:28 
QuestionNurse Rostering using Clonal Selection Algorithm Pin
rohaya887-Nov-11 19:58
rohaya887-Nov-11 19:58 
JokeRe: Nurse Rostering using Clonal Selection Algorithm Pin
Gerben Jongerius7-Nov-11 20:30
Gerben Jongerius7-Nov-11 20:30 
AnswerHints Pin
TorstenH.7-Nov-11 21:43
TorstenH.7-Nov-11 21:43 
GeneralRe: Hints Pin
rohaya8810-Nov-11 3:21
rohaya8810-Nov-11 3:21 
AnswerRe: Nurse Rostering using Clonal Selection Algorithm Pin
Richard MacCutchan7-Nov-11 22:44
mveRichard MacCutchan7-Nov-11 22:44 
QuestionCompile-time Annotation Processing [Solved] Pin
Skippums7-Nov-11 16:35
Skippums7-Nov-11 16:35 
AnswerRe: Compile-time Annotation Processing Pin
Skippums15-Nov-11 14:32
Skippums15-Nov-11 14:32 
QuestionTransfer File between client and server with TCP Socket Pin
lolostar7-Nov-11 5:39
lolostar7-Nov-11 5:39 

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.