Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Load Method

$
0
0
My problem is that it always goes to nothing to load - file is empty!
public void Loader(LinkList AccountList) throws IOException
	{
		
          
		//File AccountsFile = new File("Accounts");
		//Scanner keyboard = new Scanner(AccountsFile);
		
		//if (AccountsFile.exists())
		//{
		try
		{
		
			File AccountsFile = new File("Accounts");
			Scanner keyboard = new Scanner(AccountsFile);
			
			
		   
         
	            while(keyboard.hasNextLine())
	            {
	            
	            	//make account list empty
	    			AccountList.head = null;
	            		
	            	Account p = new Account();
	            		
	            	String AccountNumberLoaded = keyboard.nextLine();
	            	int AccountInt = Integer.parseInt(AccountNumberLoaded);
	                p.setAccountNumber(AccountInt);
	            
	               p.setName(keyboard.nextLine());
	            	         	
	                p.setAddress(keyboard.nextLine());
	            	
	                String BalanceLoaded = keyboard.nextLine();
	            	double BalanceDouble = Double.parseDouble(BalanceLoaded);
	                p.setBalance(BalanceDouble);
	                
	                AccountList.add(p);
	            	 
          	      
	            	
	            
	            }
	       
	            if(!(keyboard.hasNextLine()))
	            {
	            	System.out.println("Nothing to load - File is Empty!");
	            	
	            }
	
		       }
		
		
		      //if (!(AccountsFile.exists()))
	          catch (Exception e)
		      {
		    	  System.out.println("No File Exists!");
		      }
		    
	
				MainClass.Menu(AccountList);
			
	    }                   }


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>