Gestion des Exceptions: Comment mettre un printStackTrace() dans un String

Author:


{filelink=4365}


import java.io.PrintWriter;
import java.io.StringWriter;

public class ExempleException {
  public static void ExempleException(String args[]) {
    try {
      throw new Exception("G�n�rer une exception");
    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      System.out.println(sw.toString().toUpperCase());
    }
  }
}

A Voir sur le même Sujet:

  • la fonction printstacktrace to string
  • printstacktrace();
  • les exceptions sql dan un jframe en java
  • printstacktrace to strting
  • printstacktrace() difference avec system.out.println
  • printStackTrace() dans
  • java printstack partiel

Leave a Reply

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