Not sure if this is advanced or not but here goes:
I'm now stuck on such a simple task I have no idea what to do. I just want to take from the space all "chatRooms" then extract the chat room name which i will keep in an array, then write to the space supplying the extracted chat room name and "chatRooms". I have tried writing the object to array but no luck as it showed an object but couldn't extract name. I keep getting the following error from the code:
Error: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
public void threadchatRetrieval() { space = SpaceUtils.getSpace(); if (space == null){ System.err.println("Failed to find the javaspace"); System.exit(1);} int count = 0; Username template = new Username(null,"chatRooms"); do{ try { temp = (Username)space.take(template, null,6000); System.out.println("output: " + temp.Name); if(temp.Name.equals(null)){ System.out.print("null entry"); } else{ entry.add(0, temp.Name); count++; System.out.print("added at: " + count); } } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnusableEntryException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransactionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NullPointerException e){ System.out.println("done"); } //entry.add(temp.Name); }while(temp != null); System.out.println("output size: " + entry.size()); for (int i=0; i<= entry.size();i++) { System.out.println( "for: " + entry.get(i)); try { String Username = entry.get(i); Username template_new = new Username(Username,"chatRooms"); System.out.println( "write: " + Username); space.write(template_new, null,8000); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransactionException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }