Skip to content

Instantly share code, notes, and snippets.

@bussiere
Created November 29, 2010 10:13
Show Gist options
  • Save bussiere/719789 to your computer and use it in GitHub Desktop.
Save bussiere/719789 to your computer and use it in GitHub Desktop.
a tiny tools for debugging in java
// Write String a the end of a file
package outils;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
public class LogDebug
{
public static void ecrire(Object debug)
{
FileWriter writer = null;
try{
writer = new FileWriter("log.txt", true);
Date maDate = new Date();
String ecrituredebug = maDate.toString()+":"+debug.toString()+"\r\n";
writer.write(ecrituredebug,0,ecrituredebug.length());
}catch(IOException ex){
ex.printStackTrace();
}finally{
if(writer != null){
try
{
writer.close();
}
catch (IOException e)
{
}
}
}
//System.out.println(debug);
}
public static void ecrire(String fichier,Object debug)
{
FileWriter writer = null;
try{
writer = new FileWriter(fichier, true);
Date maDate = new Date();
String ecrituredebug = maDate.toString()+":"+debug.toString()+"\r\n";
writer.write(ecrituredebug,0,ecrituredebug.length());
}catch(IOException ex){
ex.printStackTrace();
}finally{
if(writer != null){
try
{
writer.close();
}
catch (IOException e)
{
}
}
}
//System.out.println(debug);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment