For Java (and most types of source code) you can insert small sections of code encased within [code] and [/code] UBB Code Tags
For example, I have enclosed the following code inside [code tags:
As you can see, this gives line numbers, syntax highlighting, and other cool features. If you are still not sure how I did that, click the Quote button next to my post, and you should be able to see what I did.
As far as file types for upload - we only really allow images. When we allowed plain text files and zip files, we found that people were uploading entire class projects and expecting other users to debug thousands of lines of code.