r/javahelp • • Mar 07 '13

Rewriting Unix in java?

Hey guys!

I'm doing an assignment right now in class where we have to create the unix 'cat' code, but in java, and me n my friend are soooo stuck...

does anyone have any ideas??

Thanks! :)

0 Upvotes

9 comments sorted by

View all comments

3

u/splitiron Mar 07 '13

It depends on where you're stuck. Seems like you'd want to merge a couple of FileInputStreams and append one to the other with the FileOutputStream.

0

u/ashlee_code33 Mar 07 '13

we're supposed to take any args given and display the contents of the args (which i guess are files..) on system.out... should we print these out with println? or what? thanks!!!

3

u/Nebu Writes Java Compilers Mar 07 '13

should we print these out with println? or what?

Well, try it and see if your program does what you want it to do. If it does, then you're done. If it doesn't, think about whether it'd be better to modify what you got so far, or if it'd be better to start over from scratch.

0

u/ashlee_code33 Mar 08 '13

ok well it prints the files... so am i done, or should I get rid of the print line? omg thanks so much for this btw

4

u/Nebu Writes Java Compilers Mar 08 '13

Assuming you've read the assignment, you are probably in a better position to judge whether you are done or not.

0

u/ashlee_code33 Mar 08 '13

lol, I just mean with this section.. the asignment wants me to take the files in and put them to standard out (direct quote)... this is vernacular we havent used yet...

2

u/m1ss1ontomars2k4 Mar 08 '13

Standard out is System.out in Java. So if you do System.out.println("asdf"), you've printed "asdf" to standard out. It's also possible you should use System.out.print instead of System.out.println.