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

Java free disk space

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

A request I got from a member on our forum to write an example to get the total and free diskspace left on the local harddisk. Note: Java SE 1.6 is required to run the sourcecode.

Output:
Java free diskspace demo
c:\ 111,79 Gb total 13,39 Gb left
d:\ 0,00 Gb total 0,00 Gb left
e:\ 0,00 Gb total 0,00 Gb left
f:\ 0,00 Gb total 0,00 Gb left
g:\ 0,00 Gb total 0,00 Gb left
h:\ 0,48 Gb total 0,01 Gb left

(more...)


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