このコード部分を使用しています(クラスStatsController内):
String spl_name = lne.substring(0, idx_firstnumber);
SpecialList spl = new SpecialList(spl_name);
宣言(望まれていた):
String lne = "";
int idx_firstnumber = 0;
変数 "lne" は 127 文字です。デバッグを続けると、変数「spl_name」の正しい文字が 1 つだけ表示されます。次のステップでは、特別なリスト (特別な機能を持つ通常のリスト) を作成します。
編集: 変数「idx_firstnumber」は 31 です。
コンストラクターのコードは次のとおりです。
//Klasse
public class SpecialList {
    //Variablen
    private ArrayList<SpecialListItem> _list = new ArrayList<SpecialListItem>();
    private String _name = "";
    //Konstruktor
    SpecialList(String name){
        _name = name;
    }
.. non relevant code
デバッガーとデバッグ中の値の画像: http://dancger.pf-control.de/images
そのため、F5 キーを押し続けると、プログラムがクラッシュし、「ソースが見つかりません」というエラー メッセージが表示されます。デバッグ ウィンドウには次のように表示されます。
owns: Object  ?id=2235?
ClassNotFoundException?Throwable?.<init>?String, Throwable? line: 286
ClassNotFoundException?Exception?.<init>?String, Throwable? line: not available
ClassNotFoundException?ReflectiveOperationException?.<init>?String, Throwable? line: not available
ClassNotFoundException.<init>?String? line: not available
URLClassLoader$1.run?? line: not available
URLClassLoader$1.run?? line: not available
AccessController.doPrivileged?PrivilegedExceptionAction<T>, AccessControlContext? line: not available [native method]
Launcher$ExtClassLoader?URLClassLoader?.findClass?String? line: not available
Launcher$ExtClassLoader?ClassLoader?.loadClass?String, boolean? line: not available
Launcher$AppClassLoader?ClassLoader?.loadClass?String, boolean? line: not available
Launcher$AppClassLoader.loadClass?String, boolean? line: not available
Launcher$AppClassLoader?ClassLoader?.loadClass?String? line: not available
StatsController.readdatafromfile?String? line: 108
Frm_Main.btn_show_clicked?? line: 209 
Frm_Main.access$1?Frm_Main? line: 186 
Frm_Main$3.actionPerformed?ActionEvent? line: 139
JButton?AbstractButton?.fireActionPerformed?ActionEvent? line: not available
AbstractButton$Handler.actionPerformed?ActionEvent? line: not available
DefaultButtonModel.fireActionPerformed?ActionEvent? line: not available
DefaultButtonModel.setPressed?boolean? line: not available
BasicButtonListener.mouseReleased?MouseEvent? line: not available
Some more..
プログラムを通常どおり (デバッグなしで) 実行すると、次のエラー メッセージが表示されます。
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: 31
    at java.lang.String.substring(Unknown Source)
    at business.StatsController.readdatafromfile(StatsController.java:107)
    at gui.Frm_Main.btn_show_clicked(Frm_Main.java:209)
    at gui.Frm_Main.access$1(Frm_Main.java:186)
    at gui.Frm_Main$3.actionPerformed(Frm_Main.java:139)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
そして私の質問: なぜプログラムがクラッシュしたのか、またはクラッシュするのか?
これは、文字列を要求するコンストラクタを持つ通常のクラスです。そして文字列がいっぱいです!
誰にもアイデアはありますか?
編集 2: プロジェクト全体を再構築しました。新しいコンピューター、新しい日食、新しいクラス。同じ問題。
編集 3: 問題は変数ですidx_firstnumber。31 ( の値idx_firstnumber) を取ると、うまくいきます。しかし、プログラムがこれらの変数を処理しなければならない場合、プログラムはクラッシュします。
編集 3 のため、このメソッドの完全なコード。問題はそこにあると思います:
public boolean readdatafromfile(String pth){
        //Textinhalt holen
        String[] input = fc.GetFileContentAsLines(pth);
        //Inhalt prüfen
        if (input.length == 0){
            return false;
        }
        //Aktuelle Daten löschen
        datalist.clear();
        //Aktuellen Pfad ändern
        currentpath = pth;
        //Variablen
        int idx_firstnumber = 0;
        int idx_lastnumber = 0;
        boolean bl_readpolicies = false;
        //Auslesen
        for (int idx = 0; idx < input.length;idx++){
            //Zeile bestimmen
            String lne = input[idx];
            //Index oder Daten lesen
            if (!bl_readpolicies){
                //Index LastNumber lesen
                if (lne.trim().contains("AVG")){
                    idx_lastnumber = lne.substring(0, lne.indexOf("AVG")).length();
                }
                //Index FirstNumber lesen
                if (lne.trim().startsWith("01")){ //contains
                    idx_firstnumber = lne.substring(0,lne.indexOf("01")).length();
                }
                //Anfangspunkt suchen
                if (lne.startsWith("----------")){
                    bl_readpolicies = true;
                }
            } else {
                //Abbrechen wenn keine Daten mehr kommen
                if (lne == ""){
                    break;
                }
                /*if (idx_firstnumber >= lne.length()) {
                    throw new IllegalStateException("Index " + idx_firstnumber + " out of range " + lne.length() + " [" + lne + "]");
                }*/
                //Neue SpezialListe erstellen
                String spl_name = lne.substring(0, 31);//idx_firstnumber);
                //String x = lne.
                SpecialList spl = new SpecialList(spl_name);
                //Alle Einträge auslesen
                for(int idx2 = idx_firstnumber; idx2 <= idx_lastnumber; idx+=3){
                    //Auslesen der ANzahl Stunden
                    String anzstd_string;
                    try {
                        anzstd_string = lne.substring(idx2, 2);
                    } catch (Exception e) {
                        break;
                    }
                    //Prüfen ob numerisch
                    try {
                        //Parsen
                        int anzstd = Integer.parseInt(anzstd_string);
                        //Überschritten / Standard
                        if (anzstd > 48){
                            spl.add(new SpecialListItem(anzstd,enm_valuetyp.limitexceeded));
                        } else {
                            spl.add(new SpecialListItem(anzstd,enm_valuetyp.standard));
                        }
                    } catch (Exception e) {
                        switch (anzstd_string){
                            case "-":
                                spl.add(new SpecialListItem(0,enm_valuetyp.error));
                                break;
                            case "":
                                spl.add(new SpecialListItem(0, enm_valuetyp.blank));
                                break;
                            case "*":
                                spl.add(new SpecialListItem(0,enm_valuetyp.unfinished));
                                break;
                            default:
                                System.out.println("Fail AnzStd: " + anzstd_string);
                                break;
                        }
                    }
                }
                //Daten einer Reihe hinzufügen
                datalist.add(spl);
            }
        }
        //Erfolgreiche Rückgabe
        return true;
}
編集 4: まあ、問題があると思います。変数に50倍の文字「a」を使用すると、機能しlneます。しかし、文字が許可されていないのは何ですか?!?
lneこれは、文字列からの値 (開始と終了の間の「 : 」なし)です。
start:_VXC_POLICY_ai_b0_cbw_vs_01 2 1 2 2 - - - - 1 1 1 1 1 1 1 1 :終了
前もって感謝します、greez Dancger :)