Results 1 to 3 of 3
  1. #1
    sumaih is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default String Tokenizer

    hi ,I rellay need your help.
    here when i type "rmdir"
    it takes the valur i print but i dont send it !?
    please help
    and its "doubly linked list"
    code:LLTest
    PHP Code:
    [CODE]import java.io.*;
    import java.util.*;
    public class LLTest
    {
    	public static void main(String args[])
    	{  BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 
    	
    		LL theList=new LL();
    	////	/////////////////////////////////////////////////////////////
    	String input=" ";
    		int inputcount=0;
    		String command=" ";
    			String value=" ";
    	
    	
    	////////////////////////////////////////////////////////////////////////////
    	
    	do{
    		System.out.println("   ");
    	System.out.print("Enter the new node value or exit to quit:  ");	
    		try
    		{
    			input =in.readLine();
    			System.out.println("  ");
    			
    		
    		}//end try
    		
    		catch(Exception semo)
    		{
    			System.out.println("error");
    			System.exit(1);	
    		}
    		
    	//	if(input.equals("exit"))
    	//	break;
    		//////////////////////////////////////////////////
    		///////////////////////////////////////////////
    		StringTokenizer st = new StringTokenizer(input);
    	inputcount=st.countTokens() ;
    command=st.nextToken();
    
    	if(command.equals("mkdir"))
    {
    	
    if(st.hasMoreTokens())
    
    {
    	value=st.nextToken();
    	
    	if(theList.Chick(value)) {
    
    	theList.insertlast(value);
    	System.out.println("   ");
    	System.out.println("Create new directory "+value);
    	System.out.println("   ");
    	theList.print();
    	
    	
    	}//end 3 if
    	else{
    		System.out.println("Error The node already exist");
    		
    	}
    	
    }//end 2 if
    else
    	{
    			System.out.println("Error  in Directory node ");
    		
    	}
    	}//end 1 if
    	else if(command.equals("rmdir"))
    	{
    if(st.hasMoreTokens())	
    {
    
    
    	value=st.nextToken();
    	theList.delete(value);
    			theList.print();
    if(!theList.Chick(value)) {
    	System.out.println("   ");
    	System.out.println(" delete directory "+value);// 
    	theList.delete(value);
    	System.out.println("   ");
    
    		
     theList.print();
    	}
    	
    	
    	}//end 3 if
    		
    	
    	else
    	{	theList.delete(value);
    	System.out.println("   ");
    		System.out.println(" delete directory "+value);// 
    			System.out.println("   ");
    		//System.out.println("Error");
    	}
    	
    	}
    	
    		
    	}while(!input.equals("exit"));
    
    }
    }
    //end class[/CODE]

    code :LL
    Java Code:
    public class LL
    {//	private Node first;
    //	private Node last;
    	
    private Node first=new Node();
    	
    	private Node last=first;
    	
    	
    		
    		
    		public boolean isEmpty()
    		{
    			return(first==null);
    		}
    		
    	
    			public void insertlast( String  iData)
    		{
    			Node newNode =new Node(iData );
    			
    			if(isEmpty())
    			{
    
    		first=newNode;
    	//	last=newNode;
    			
    		}
    		else
    	{	last.next=newNode;
    		newNode. previous=last;
    	//	ast=newNode; l//on both type
    		}
    		
    		last=newNode;
    		
    		
    }
    
    
    
    
    public Node delete(String key)
    { Node current = first.next;
    	while(current.item!= key)
    	{current=current.next ;
    	if(current==null)
    	 return null;
    		
    	}
    	if(current.next==null)
    	{last.previous.next=null ;
    	  last=current.previous ;}
    else
    { 
    	 
    	 while(last!=current)
    	 {
    	  last.previous.next=null ;
    	 last=last.previous;
    	 }
    	   last.previous.next=null ;
    	 last=current.previous;
    	 
                                     
    }
    
    
    	return current;        
    }
    	public void print()
    	{  Node temp=first;
    	  while(temp!=null)
    	  { System.out.printf("<%s> ",temp.item);
    	  
    	  temp=temp.next;
    	  }
    	   System.out.println("");
    	}
    		public boolean Chick(String newNode)
    	{
    		Node temp=first;
    		while(temp!=null)
    		{
    			if(newNode.equalsIgnoreCase(temp.item) ) //here I do not know what is the condition
    			return false;
    			temp=temp.next;
    		}//end while
    		return true;
    	}//end method
    	
    /*	public static void main (String args[])
    	{
    		LL ob =new LL () ;
    		ob.insertlast("a");
    		ob.insertlast("b");
    		ob.insertlast("c");
    		ob.insertlast("d");
    		ob.print();
    	//	ob.delete("d");
    //	ob.print();	
    	ob.delete("b");
    	ob.print();
    		
    	}*/
    
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,548
    Rep Power
    23

    Default

    when i type "rmdir"
    it takes the valur i print but i dont send it !?
    Can you explain what you mean here?

    Can you copy and paste here the contents of the console when you execute the program and that shows the problem?

    To copy the contents of the command prompt window on Windows:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. String Tokenizer
    By hussainian in forum Advanced Java
    Replies: 1
    Last Post: 03-16-2010, 08:58 AM
  2. String Tokenizer
    By viperlasson in forum New To Java
    Replies: 1
    Last Post: 03-09-2010, 01:14 PM
  3. String Tokenizer
    By redasu in forum Advanced Java
    Replies: 4
    Last Post: 02-19-2010, 03:30 AM
  4. string tokenizer
    By twinytwo in forum New To Java
    Replies: 2
    Last Post: 03-26-2009, 02:10 PM
  5. Problem with string tokenizer
    By twinytwo in forum AWT / Swing
    Replies: 2
    Last Post: 03-26-2009, 11:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •