Note that there are some explanatory texts on larger screens.

plurals
  1. POtrouble with StringTokenizer
    primarykey
    data
    text
    <p>I'm getting the following error message and I can't seem to figure out the problem. Would really appreciate any help. The error message reads as:-</p> <p>BaseStaInstance.java:68: cannot find symbol </p> <p>symbol : constructor StringTokenizer(java.lang.Object,java.lang.String)</p> <p>location: class java.util.StringTokenizer st = new StringTokenizer(buf,",");</p> <pre><code> ^ </code></pre> <p>Here, BaseStaInstance is my main public class.</p> <p>The class that implements this StringTokenizer is as follows:-</p> <p>class ServerConnect extends Thread {</p> <pre><code>Socket skt; int iProcessId, iInProcessId; int iOwnTimeStamp, iInTimeStamp; ServerConnect scnt = null; ObjectOutputStream myOutput; ObjectInputStream myInput; ServerConnect(){} ServerConnect(Socket connection, int iProcessNo) { this.skt = connection; this.iProcessId = iProcessNo; } public void run() { try { //initialize the object "scnt" using the parameterized constructor ServerConnect scnt = new ServerConnect(skt, iProcessId); myInput = new ObjectInputStream(skt.getInputStream()); while(true) { try{ iOwnTimeStamp = Global.iTimeStamp; Object buf = myInput.readObject(); //if we got input, print it out and write a message back to the remote client... if(buf != null){ scnt.replyChoice(buf); } }catch(ClassNotFoundException e) { e.printStackTrace(); } } } catch(IOException e) { e.printStackTrace(); } } void replyChoice(Object buf){ try{ String sDeferReply = ""; myOutput = new ObjectOutputStream(skt.getOutputStream()); //the place where the basestation reads the request from the other basestation System.out.println("Server read:[ "+buf+" ]"); //extract out the process id and the timestamp from the incoming request buf = buf.toString(); ***StringTokenizer st = new StringTokenizer(buf,",");*** //skip the word request st.nextToken(); iInProcessId = Integer.parseInt(st.nextToken()); iInTimeStamp = Integer.parseInt(st.nextToken()); //check request is made //there is a possibility of entering the else loop only on the very first iteration //the control flows into the if loop even if one request has been made if(iOwnTimeStamp != 0){ //if the incoming request has a larger timestamp (logical clock value, process id) than the current process, we defer the reply if(iOwnTimeStamp &lt; iInTimeStamp || iProcessId &lt; iInProcessId){ sDeferReply="iInTimeStamp"+","+"iInProcessId"; Global.v.addElement(new String(sDeferReply)); } //incoming request has a smaller timestamp than the basestation request itself else{ myOutput.writeObject("Reply"); myOutput.flush(); } } //if the current process is in the critical section then we defer replies else if(Global.iCriticalSection==1){ sDeferReply="iInTimeStamp"+","+"iInProcessId"; Global.v.addElement(new String(sDeferReply)); } //start of execution of the thread, there is a possibility that the basestation hasn't issued a request else{ myOutput.writeObject("Reply"); myOutput.flush(); } }catch(IOException e){ e.printStackTrace(); } } </code></pre> <p>} </p> <p>The part that implements the StringTokenizer function has *** surrounding it.</p> <p>Thanks in advance to anyone who might be able to help me out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload