Engineeringserver.com

A community for computer science students & developers about software development, game development, game design, games, anime preview & reviews and more!


Read a textfile into an ArrayList

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...
514 views
JAVA:
  1. /*--------------------------------------------------------------------------
  2. ScanToArrayDemo class
  3. *****************
  4. By: HappyFace   http://www.engineeringserver.com
  5. Contact:        info [@] engineeringserver.com
  6. Version:        10/September/2008
  7. "*****************
  8. Note: Read a textfile into an ArrayList
  9. //----------------------------------------------------------------------*/
  10. import java.io.File;
  11. import java.io.FileNotFoundException;
  12. import java.io.IOException;
  13. import java.util.ArrayList;
  14. import java.util.Scanner;
  15.  
  16. public class ScanToArrayDemo {
  17. public static void main(String[] args){
  18. File fInput     = new File("c:\\input.txt");
  19. ArrayList textHolder = new ArrayList();
  20. String tmp = "";
  21. try {
  22. Scanner scInput = new Scanner(fInput);
  23. while (scInput.hasNextLine()){
  24. tmp = scInput.nextLine();
  25. textHolder.add(tmp);
  26. }
  27. }
  28. e.printStackTrace();
  29. }
  30. catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33. //display the content of the array
  34. System.out.println(textHolder.get(3));
  35. }
  36. }


Your Ad Here

Scan your harddisk with Java

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.5 out of 5)
Loading ... Loading ...
456 views

It took me a few hours but i've managed to write an application that scans a harddisk to show directories, subdrectories and filesize etc. It took me so long to write this one because I had some trouble accessing subdirectories but i've sorted that one out. Everything is now dynamically done and should work fine.

I'll release if after some more testing and I'll will also a few other features such as writing the results to disk and maybe a GUI for easy navigation trough the application. After thats done i'll release the sourcecode here so you can play with it yourself.
(more...)


Your Ad Here

How to count the frequency of the same characters in a string

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5 out of 5)
Loading ... Loading ...
417 views

Here's a demo I made that counts the frequency/occurences in a given string. Took me an hour or so to write it but it was fun to do so on a boring sunday. It also counts a few special character such as spaces and brackets etc.
(more...)


Your Ad Here