ich muss doch ein datei lesen mit eine methode public readXml(String fname){}
public void readFromFile(String filename) {
// BufferedInputStream bufferedInput = null;
// byte[] buffer = new byte[4024];
Vector dat = new Vector();
try {
String zeile;
f= new File(filename);
fr = new FileReader(f);
br = new BufferedReader(fr);
zeile=br.readLine().trim();
zeile= br.readLine().trim();
while( zeile!="</ERgebnis>"){
if(zeile.charAt(1)=='E'){
int begin = zeile.indexOf("=")+3;
int ende = zeile.length()-3;
String sub = zeile.substring(begin,ende);
System.out.println(sub);
person.setInfo(0, br.toString());
dat.add(person);
}
}
while(zeile!="</TrainingSet>")
{
if(zeile.charAt(1)=='T'){
zeile = br.readLine().trim();
dat.add(person);
int begin = zeile.indexOf("=")+3;
int ende = zeile.length()-3;
String sub = zeile.substring(begin,ende);
System.out.println(" "+sub);
person.setInfo(1, br.toString());
dat.add(person);
}
}
zeile = br.readLine().trim();
dat.add(person);
br.close();
}
catch (FileNotFoundException fnfe)//
{
fnfe.printStackTrace();
System.exit(0);
System.out.println("Datei nicht gefunden");
}
catch(IOException e)
{
System.out.println("Fehler beim Lesen der Datei");
}
wie kann man ein xml-datei lesen und in einem vector speicher die ausgabe soll zum Beispiel so sein:
1 1
1 2
1 3
1 4
1 5
...
.
.
.
1 45
2 1
2 2
2 3
2 4
2 5
2 6
....
.
.
.
2 45.
fname= "MyXmlFile.xml";
public String readXML(String fname){}
und das ist die xml-datei:
<?xml version='1.0' encoding='utf-8'?><!-- MyXmlFile.xml -->
<GUI-Description>
<ERgenis index ="1">
-<TrainningSet setIndex ="1>
<erro>0.000344</error>
<TrainningSet/>
-<TrainningSet setIndex ="2">
<erro>0.0003487</error>
<TrainningSet/>
-<TrainningSet setIndex ="3">
<erro>0.0013487</error>
<TrainningSet/>
-<TrainningSet setIndex ="4">
<erro>0.0010487</error>
<TrainningSet/>
.
.
.
-<TrainningSet setIndex ="45">
<erro>0.0313487</error>
<TrainningSet/>
</ERgebnis>
- <ERgenis index ="2">
-<TrainningSet setIndex ="1>
<erro>0.000344</error>
<TrainningSet/>
-<TrainningSet setIndex ="2">
<erro>0.0003487</error>
<TrainningSet/>
-<TrainningSet setIndex ="3">
<erro>0.0013487</error>
<TrainningSet/>
-<TrainningSet setIndex ="4">
<erro>0.0010487</error>
<TrainningSet/>
.
.
.
-<TrainningSet setIndex ="45">
<erro>0.0313487</error>
<TrainningSet/>
</ERgebnis>
<GUI-Description/>
hat jeamnden eine Idee?
meine klasse heisst:
public ERgebnis(int Index){
/*The constructor for an EpochResult instance.
* A positive epoch index should be provided;
* otherwise, though the EpochResult instance
* will be created, the repository will not
* treat it as a valid instance.
The instance will be initialized.
Parameters:
epochIndex - the epoch index. Should not be 0 or negative.*/
if(epochIndex <= 0)
epochIndex = STANDARD_VALUE;
this.epochIndex= epochIndex;
}
public int getIndex(){
/* Retrieve the epoch index of this instance. Only positive integer values are
* valid epoch indices. A zero return value indicates that this instance has not
* yet been given a proper epoch index; this typically happens if a constructor
* call with invalid epochIndex value has been invoked.
Returns:
the epoch index of this instance
*/
if(epochIndex >0)
return epochIndex;
}
public void setIndex(int newIndex){
/* Set the epoch index. Only positive values are allowed.
* In case a negative or zero value is provided to this method,
* nothing will change within this instance.
Parameters:
newIndex - the index value to be set*/
Index = newIndex ;
}
public int[] getTrainingResultSetIndices( int setIndex){
/* Retrieve the list of setIndex values of all training result sets available in this epoch.
* They are returned as an integer array. Note, that the setIndex values appear unsorted
* in any order (as they have been entered into the epoch). Note also, that this only means
* there is at least one of the following information items available for that setIndex: a
* set name, an output error, an output data set, and/or a resulting net configuration.
If there are none (yet), an array of length 0 is returned.
Returns:
array with setIndex values available in this epoch.
*/
}
hat jemanden eine idee? danke im voraus!
public void readFromFile(String filename) {
// BufferedInputStream bufferedInput = null;
// byte[] buffer = new byte[4024];
Vector dat = new Vector();
try {
String zeile;
f= new File(filename);
fr = new FileReader(f);
br = new BufferedReader(fr);
zeile=br.readLine().trim();
zeile= br.readLine().trim();
while( zeile!="</ERgebnis>"){
if(zeile.charAt(1)=='E'){
int begin = zeile.indexOf("=")+3;
int ende = zeile.length()-3;
String sub = zeile.substring(begin,ende);
System.out.println(sub);
person.setInfo(0, br.toString());
dat.add(person);
}
}
while(zeile!="</TrainingSet>")
{
if(zeile.charAt(1)=='T'){
zeile = br.readLine().trim();
dat.add(person);
int begin = zeile.indexOf("=")+3;
int ende = zeile.length()-3;
String sub = zeile.substring(begin,ende);
System.out.println(" "+sub);
person.setInfo(1, br.toString());
dat.add(person);
}
}
zeile = br.readLine().trim();
dat.add(person);
br.close();
}
catch (FileNotFoundException fnfe)//
{
fnfe.printStackTrace();
System.exit(0);
System.out.println("Datei nicht gefunden");
}
catch(IOException e)
{
System.out.println("Fehler beim Lesen der Datei");
}
wie kann man ein xml-datei lesen und in einem vector speicher die ausgabe soll zum Beispiel so sein:
1 1
1 2
1 3
1 4
1 5
...
.
.
.
1 45
2 1
2 2
2 3
2 4
2 5
2 6
....
.
.
.
2 45.
fname= "MyXmlFile.xml";
public String readXML(String fname){}
und das ist die xml-datei:
<?xml version='1.0' encoding='utf-8'?><!-- MyXmlFile.xml -->
<GUI-Description>
<ERgenis index ="1">
-<TrainningSet setIndex ="1>
<erro>0.000344</error>
<TrainningSet/>
-<TrainningSet setIndex ="2">
<erro>0.0003487</error>
<TrainningSet/>
-<TrainningSet setIndex ="3">
<erro>0.0013487</error>
<TrainningSet/>
-<TrainningSet setIndex ="4">
<erro>0.0010487</error>
<TrainningSet/>
.
.
.
-<TrainningSet setIndex ="45">
<erro>0.0313487</error>
<TrainningSet/>
</ERgebnis>
- <ERgenis index ="2">
-<TrainningSet setIndex ="1>
<erro>0.000344</error>
<TrainningSet/>
-<TrainningSet setIndex ="2">
<erro>0.0003487</error>
<TrainningSet/>
-<TrainningSet setIndex ="3">
<erro>0.0013487</error>
<TrainningSet/>
-<TrainningSet setIndex ="4">
<erro>0.0010487</error>
<TrainningSet/>
.
.
.
-<TrainningSet setIndex ="45">
<erro>0.0313487</error>
<TrainningSet/>
</ERgebnis>
<GUI-Description/>
hat jeamnden eine Idee?
meine klasse heisst:
public ERgebnis(int Index){
/*The constructor for an EpochResult instance.
* A positive epoch index should be provided;
* otherwise, though the EpochResult instance
* will be created, the repository will not
* treat it as a valid instance.
The instance will be initialized.
Parameters:
epochIndex - the epoch index. Should not be 0 or negative.*/
if(epochIndex <= 0)
epochIndex = STANDARD_VALUE;
this.epochIndex= epochIndex;
}
public int getIndex(){
/* Retrieve the epoch index of this instance. Only positive integer values are
* valid epoch indices. A zero return value indicates that this instance has not
* yet been given a proper epoch index; this typically happens if a constructor
* call with invalid epochIndex value has been invoked.
Returns:
the epoch index of this instance
*/
if(epochIndex >0)
return epochIndex;
}
public void setIndex(int newIndex){
/* Set the epoch index. Only positive values are allowed.
* In case a negative or zero value is provided to this method,
* nothing will change within this instance.
Parameters:
newIndex - the index value to be set*/
Index = newIndex ;
}
public int[] getTrainingResultSetIndices( int setIndex){
/* Retrieve the list of setIndex values of all training result sets available in this epoch.
* They are returned as an integer array. Note, that the setIndex values appear unsorted
* in any order (as they have been entered into the epoch). Note also, that this only means
* there is at least one of the following information items available for that setIndex: a
* set name, an output error, an output data set, and/or a resulting net configuration.
If there are none (yet), an array of length 0 is returned.
Returns:
array with setIndex values available in this epoch.
*/
}
hat jemanden eine idee? danke im voraus!
