Bonjour à vous,
Je débute en java, et j'ai un petit souci sur une StackTrace que j'ai mis en place.
Le problème vient du fait qu'il me retourne des lignes et des lignes d'exception. Du coup ma pop up est très grande et quasi inutilisable.

Je voulais savoir comment faire pour récupérer que les 30 dernières lignes ??
Voila la classe créée :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
package eu.efa.commons;
 
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
 
public class EfaStackTrace {
 
	public static String stringify ( Throwable exn ) {
		StringWriter str = new StringWriter();
		PrintWriter pw = new PrintWriter( str );
		pw.println( exn.getClass().getName () );
		pw.println( String.valueOf( exn.getMessage() ) );
		pw.println( dup( "====", 20 ) );
		exn.printStackTrace( pw );
		pw.println( dup( "====", 20 ) );
		if( exn.getCause() != null ) {
			pw.println( stringify( exn.getCause() ) ); }
		return str.toString(); }
 
	private static String dup ( String motif, int count ) {
		StringWriter os = new StringWriter();
		PrintWriter pw = new PrintWriter( os );
		while( count-- > 0 ) {
			pw.print( motif ); }
		return os.toString(); }
 
	private static class Exn extends Exception {
		private static final long serialVersionUID = -1L;
		public Exn () {
			super(); } }
 
	private static void badComputationAux ()  {
		try {
			throw new Exn(); }
		catch( Exception exn ) {
			throw new RuntimeException( exn ); } }
 
	public static void main ( String[] args ) {
		try {
			badComputationAux(); }
		catch( Throwable exn ) {
			System.err.println( EfaStackTrace.stringify( exn ) ); } } 
}
Pourriez vous me dire comment récupérer uniquement les 30 dernières lignes ?
Merci.