Main has 2 parameters. The first is "file"; you can supply your own output of linux "ps -e" command, but I've supplied my test output (processSnapshot.txt) in case you don't have access to linux. The second is optional, and is the number of lines in "file". Main creates a file "output04.dat" that stores the serialized data. Process is the primary object of this project, and holds an int pid (process ID) and 3 strings for TTY, time active, and the command that initiated the process. ProcessData handles writing bytes to file and all access to the output file. There are some methods in ProcessData that probably fit better in a separate class, but I'll leave that for the next bit manipulation project.
The output04.dat file was actually larger on my system (5.9KB), than the "ps -e" output (5.7KB). This was due to all the padding spaces I used to maintain a set record size. I am aware of the Serializable interface, but I wanted to write and decode individual bytes to better my byte manipulation skills. Later I'll try writing individual packets to a network stream, or making a very basic database program.
Attached Files
Edited by existentialist, 12 December 2010 - 12:12 AM.


Sign In
Create Account




Back to top









