DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2005
    Posts
    6

    Unhappy read/write to file in java applet

    last time, i have read in the internet that java applet don't allow the users to read/write to file...but i found this one website that teaches how to open or write to file in java applet....

    http://www.captain.at/programming/java/

    after i follow the instruction, 2 files created which is TicketInterface.crt and TicketInterface.jar (i have class called TicketInterface which extends JApplet)

    besides that, i have 2 classes which are Admin and User...The User class have some attributes and methods which related to Write and Read Files (BufferedReader...BufferedWriter...something like that)....The Admin class don't have any of the attributes or methods which related to Write or Read Files...The TicketInterface class will call some of the methods from the User class as well as Admin class....

    the problem is i still can't open or write to file...Supposely, the TicketInterface class will call the method from User class so that it can write or read to file...

    this is some of the portion taken from User class :-

    Code:
    	/////////////////////return LOGIN USER TRUE FALSE////////////////////////////////////
    	public boolean LoginUser() throws IOException 
    	{
    	
    		BufferedReader inputusername = new BufferedReader (new FileReader("username.txt"));
    		BufferedReader inputpassword = new BufferedReader (new FileReader("password.txt"));
    		
    		while((UsernameArray[i] = inputusername.readLine()) != null)
    		{		
    				
    				if ((UsernameArray[i]).equals (Username))
    				{
    					i++;
    					flag = true;
    				
    				
    				}
    				
    				else
    				flag = false;
    				
    			
    		}
    		
    		inputusername.close();
    				
    		while((PasswordArray[i] = inputpassword.readLine()) != null)
    		{		
    				
    				if ((PasswordArray[i]).equals (Password))
    				{
    					i++;
    					flag2 = true;
    				
    				
    				}
    				
    				else
    				flag2 = false;
    				
    			
    		}
    		
    		inputpassword.close();
    		
    		if (flag == true && flag2 == true)
    		{
    			return true;
    		}
    		
    		else
    		return false;
    		
    			
    	}
    this is some of the portion taken from TicketInterface class :-

    Code:
     if (e.getSource() == OkPassLoginUser) // call OK button for PASSWORD LOGIN USER
        {
          getContentPane().remove(TextFieldPassLoginUser);
          PasswordLoginUser = PassLoginUser.getText();
          
          try
          {
          	User u2 = new User(UsernameLoginUser, PasswordLoginUser);
          	flag = u2.LoginUser();
          
          		if (flag == true)
          		{
          				MainMenuAdmin();
          		}
          	
          		else
          		{
          				setCenterPan(PanelError);
          		}
          
      	  }
      	  
      	  catch (IOException ex)
      	  {
      	  		ex.printStackTrace();
      	  }
          
          
        }
    there is a screenshot after i sign my applet (after i follow the instruction from the above website)...i also attach the files which are created after i follow the instruction from the above website
    Attached Files

Similar Threads

  1. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM
  2. Java Applet to display the log file
    By Calis in forum Java
    Replies: 3
    Last Post: 08-05-2002, 02:50 PM
  3. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 12:43 AM
  4. Java Applet won't work via browsers
    By Graham in forum Java
    Replies: 1
    Last Post: 02-20-2001, 01:47 AM
  5. how to read text file using JAVA...??
    By Billy in forum Java
    Replies: 3
    Last Post: 02-02-2001, 08:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links