| | |
how to store item and invoke from it
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I don't know what you are asking for. Can you clarify?
Can you show an example of what you are trying to do and what problem you are having with getting it to work?
It also helps if you ask specific questions.
Can you show an example of what you are trying to do and what problem you are having with getting it to work?
It also helps if you ask specific questions.
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
•
•
Join Date: Sep 2005
Posts: 3
Reputation:
Solved Threads: 0
while (line!=null)
{
tokens = new StringTokenizer(line, ",",false);
String assessNameToken = tokens.nextToken();
if((tokens.hasMoreTokens()) );
int maxScoreToken = Integer.parseInt(tokens.nextToken());
int scaleScoreToken = Integer.parseInt(tokens.nextToken());
descript[size] = new Assessment(assessNameToken, maxScoreToken, scaleScoreToken);
size++;
line = readDescription.readLine();
}
is almost like tat..i wanted to read the string file...but i dont think it can uses the parseString..i wanted to store into an array and called it afterward for further use...i dunno whether i make the question clear o not??
{
tokens = new StringTokenizer(line, ",",false);
String assessNameToken = tokens.nextToken();
if((tokens.hasMoreTokens()) );
int maxScoreToken = Integer.parseInt(tokens.nextToken());
int scaleScoreToken = Integer.parseInt(tokens.nextToken());
descript[size] = new Assessment(assessNameToken, maxScoreToken, scaleScoreToken);
size++;
line = readDescription.readLine();
}
is almost like tat..i wanted to read the string file...but i dont think it can uses the parseString..i wanted to store into an array and called it afterward for further use...i dunno whether i make the question clear o not??
•
•
Join Date: May 2005
Posts: 55
Reputation:
Solved Threads: 1
Firstly,
The line with the code
is basically useless. This checks if there are tokens and does nothing. What you want is
Also, you might want to use the trim() function when getting tokens. This cleans out the string of weird spaces at the beginning and end:
For more help, www.NeedProgrammingHelp.com
The line with the code
Java Syntax (Toggle Plain Text)
if((tokens.hasMoreTokens()) );
Java Syntax (Toggle Plain Text)
if((tokens.hasMoreTokens()) ) { //put code here }
Java Syntax (Toggle Plain Text)
String someTokenHere = tokens.nextToken().trim();
•
•
Join Date: Sep 2005
Posts: 3
Reputation:
Solved Threads: 0
import java.io.*;
import java.util.*;
public class try2
{
public static void main(String[] args)
{
Assessment[] result= new Assessment[10];
String line,line1, subjectName,token;
int lineNum=0;
int size=0;
int time=0;
try
{
BufferedReader readResult= new BufferedReader(new FileReader("ResultFile.txt."));
subjectName = readResult.readLine();
line = readResult.readLine();
StringTokenizer tokens;
while (line!=null)
{
tokens = new StringTokenizer(line, ",",false);
String studentIdToken = tokens.nextToken();
if(tokens.hasMoreTokens() );
String studentToken = tokens.nextToken();
String assessmentItemToken = tokens.nextToken();
double assessmentMarkToken = Double.parseDouble(tokens.nextToken());
result[size] = new Assessment(studentIdToken, studentToken, assessmentItemToken,assessmentMarkToken);
size++;
line = readResult.readLine();
}
System.out.println(subjectName); // check whether the infomation have been stored
System.out.println(result[2].getStudentId());
System.out.println(result[3].getStudent());
System.out.println(result[4].getAssessmentItem());
System.out.println(result[4].getAssessmentMark());
}
catch(FileNotFoundException e)
{
System.err.println("file not found");
}
catch(IOException e)
{
System.err.println(e);
}
}
}
class Assessment
{
private String student, assessmentItem;
private int studentId;
private double assessmentMark;
public Assessment(String name,String item, int id, double mark)
{
student=name;
assessmentItem=item;
studentId=id;
assessmentMark=mark;
}
public double getAssessmentMark()
{
return assessmentMark;
}
public int getStudentId()
{
return studentId;
}
public String getAssessmentItem()
{
return assessmentItem;
}
public String getStudent()
{
return student;
}
}
i still dunno wat happen to my program..it says tat cannot find the symbol constructor.
import java.util.*;
public class try2
{
public static void main(String[] args)
{
Assessment[] result= new Assessment[10];
String line,line1, subjectName,token;
int lineNum=0;
int size=0;
int time=0;
try
{
BufferedReader readResult= new BufferedReader(new FileReader("ResultFile.txt."));
subjectName = readResult.readLine();
line = readResult.readLine();
StringTokenizer tokens;
while (line!=null)
{
tokens = new StringTokenizer(line, ",",false);
String studentIdToken = tokens.nextToken();
if(tokens.hasMoreTokens() );
String studentToken = tokens.nextToken();
String assessmentItemToken = tokens.nextToken();
double assessmentMarkToken = Double.parseDouble(tokens.nextToken());
result[size] = new Assessment(studentIdToken, studentToken, assessmentItemToken,assessmentMarkToken);
size++;
line = readResult.readLine();
}
System.out.println(subjectName); // check whether the infomation have been stored
System.out.println(result[2].getStudentId());
System.out.println(result[3].getStudent());
System.out.println(result[4].getAssessmentItem());
System.out.println(result[4].getAssessmentMark());
}
catch(FileNotFoundException e)
{
System.err.println("file not found");
}
catch(IOException e)
{
System.err.println(e);
}
}
}
class Assessment
{
private String student, assessmentItem;
private int studentId;
private double assessmentMark;
public Assessment(String name,String item, int id, double mark)
{
student=name;
assessmentItem=item;
studentId=id;
assessmentMark=mark;
}
public double getAssessmentMark()
{
return assessmentMark;
}
public int getStudentId()
{
return studentId;
}
public String getAssessmentItem()
{
return assessmentItem;
}
public String getStudent()
{
return student;
}
}
i still dunno wat happen to my program..it says tat cannot find the symbol constructor.
![]() |
Similar Threads
- Removing an item from head of linked list (C)
- Checking for duplicates in a orderedered linked list (C++)
- On The Fly Edit (PHP)
- How can I use the Checkboxes into a Tree Control (C++)
- adding totals in listboxes (Visual Basic 4 / 5 / 6)
Other Threads in the Java Forum
- Previous Thread: Please help me in string operation problem
- Next Thread: site menu
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arc arguments array arrays automation binary bluetooth c++ chat class classes client code codesnippet component csv database doctype draw ebook eclipse error event exception fractal freeze game givemetehcodez graphics gui html ide image input integer intellij iphone j2me java java.xls javaprojects jmf jni jpanel julia linux list loop loops mac map method methods mobile netbeans newbie number online oracle page parameter plazmic print problem program programming project recursion reporting rotatetext scanner screen sell server set size sms socket sort sourcelabs sql string superclass swing system template test testautomation threads time title tree tutorial-sample windows working





