Comment Transformer en String le resultat de printStackTrace

Author:


{filelink=4369}

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
public class Exemple {

  public static final String stackTrace(Throwable e)
  {
      String  excep = null;
      try
      {

          ByteArrayOutputStream ostr = new ByteArrayOutputStream();
          e.printStackTrace( new PrintWriter(ostr,true) );
          excep = ostr.toString(); //Utilisation de la méthode toString()
      }
      catch (Exception ex)
      {
          System.out.println("Rien à faire ici");
      }
      return excep;
  }
}

A Voir sur le même Sujet:

  • printstacktrace to strting

Leave a Reply

Your email address will not be published. Required fields are marked *