I actually asked the exact question here: http://tex.stackexchange.com/questions/87646/problem-formatting-java-code-in-my-latex-document-overshooting-the-page
However I have tried using the solution I was given (which did work for the example I used them) but it seems that this does not work with the package I want to use (example below).
I have looked through the texdoc file for captions and floats and could not find anything on how to do it either.
\usepackage{float}
\usepackage{caption}
\begin{document}
\floatstyle{ruled}
\newfloat{program}{thp}{lop}
\floatname{program}{Program}
\begin{program}
\begin{verbatim}
if(args.length>0){
while(expression){
BufferedReader xReader=new BufferedReader(new FileReader(IOUtil.fileName(args[0])));
`BufferedReader yReader=new BufferedReader(new FileReader(IOUtil.fileName(args[1]))); } }`
\end{verbatim}
\caption{}
\end{program}
\end{document}
