Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Guten Tag,

ich bin ein Programm am schreiben, welches Datensäte aus einer Textdatei einliest.

Nun will ich diese Datensätze sortieren und in einer neuen Textdatei speichern.

Doch ich habe keine Ahnung wie ich die Sortierung realisieren soll.

Die Datensätze haben folgendes Format:

05111000005780009 0001550310111970111604351517894612333200000011000000000000000000

05111000005780010 0001550330111987021300000000051110000000000011006120001 5506502

05111000005780011 0001550310111351351515412221051188993500000011000000000000000000

05111000005780012 0001554785111971021100000000051110000000000011000000000000000000

05111000005780014 0001550320121369258619920117091620000511100012005780014 5503201

05111000005780016 0001550320111970020100000077777777777777777774440000000000000000

Es soll nach dem Bereich, der in roter Schrift hervorgehoben ist, aufsteigend sortiert werden.

Ich würde mich sehr über Hilfe freuen.

Mit freundlichen Grüßen,

T1m

Also

Hier ein kleines Beispiel :



public class TestDatensatz implements Comparable{


	int Feld1;

	int Feld2;

	int Feld3;


	@Override

	public int compareTo(Object o) {

		if (o!=null && o instanceof TestDatensatz){

			TestDatensatz rD0=(TestDatensatz)o;

			[B]if (rD0.getFeld1()<getFeld1()){

				return 1;

			} else if (rD0.getFeld1()>getFeld1()){

				return -1;

			}[/B]

		}

		return 0;

	}


	public int getFeld1() {

		return Feld1;

	}


	public void setFeld1(int feld1) {

		Feld1 = feld1;

	}


	public int getFeld2() {

		return Feld2;

	}


	public void setFeld2(int feld2) {

		Feld2 = feld2;

	}


	public int getFeld3() {

		return Feld3;

	}


	public void setFeld3(int feld3) {

		Feld3 = feld3;

	}


}


Was du mit diesen Datensätzen dann machen kannst ist z.B.

Sie in eine List<TestDatensatz> speichern und über

Collections.sort(liste); sortieren.

Da gibt es dann aber auch noch Comparatoren. Aber das dir da Google nicht hilft, bezweifele ich :)

Edit: splitte erstmal die Zeile an Hand des " "

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.