Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public static void decompressFile(Scanner console, LinkedList<String> client){
  2. /** Counts number of bytes in the compressed file */
  3. int compressed = 0;
  4.  
  5. /** Counts number of bytes in the uncompressed file */
  6. int uncompressed = 0;
  7.  
  8. String nextWord = "";
  9. char nextChar = console.next().charAt(0);
  10. while(nextChar != 0){
  11. if(Character.isLetter(nextChar)){
  12. nextWord += nextChar;
  13. } else {
  14. if(!nextWord.equals("")){
  15. if(Character.isDigit(nextChar)){
  16. nextWord += nextChar;
  17. int index = Integer.parseInt(nextWord);
  18. // Look up the word in the list and move it up the list
  19. nextWord = client.lookAtItemN(index);
  20. System.out.print(nextWord);
  21. client.remove(index);
  22. client.addToFront(nextWord);
  23. nextWord = "";
  24. } else {
  25. System.out.print(nextWord);
  26. client.addToFront(nextWord);
  27. nextWord = "";
  28. }
  29. }
  30. System.out.print(nextChar);
  31. }
  32. nextChar = console.next().charAt(0);
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement