I've spent few days already trying to properly include a Java source file dynamically in a tex file. The text is included. However the lines don't wrap.
The following is the "srinked" project
\documentclass{article}
\usepackage[left=2.54cm, right=2.54cm, top=2.54cm, bottom=2.54cm]{geometry}
\usepackage{listings}
\usepackage{adjustbox}
\usepackage{wrapfig}
%%\usepackage[none]{hyphenat}
\usepackage[T1]{fontenc}
\usepackage[cp1252]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx}
\graphicspath{{images/}{../images/}}
%% All duplicates have been commented out
\usepackage[ampersand]{easylist}
\usepackage{ulem}
\usepackage{csquotes}
\newcommand{\quotes}[1]{``#1''}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{calc, shapes, backgrounds}
\usepackage{amsmath, amssymb}
\usepackage{verbatim}
\usepackage{pdflscape}
\usepackage{wallpaper}
\usepackage{framed}
\usepackage{float}
\lstdefinestyle{MyJavaListStyle} {
numbers=left,
language=Java,
backgroundcolor={\color{yellow}},
breaklines=true
}
\usepackage{filecontents}
\begin{document}
Begining of the document.
\begin{filecontents*}{file.java}
}
static void testMe() {
String[][] arrTest = {
{ "John ", "Doe", "24a", "121", "new McGill College",
" a Suite 32", "2r223", "Montréal Name Of The Town1"
"", "Québec", "K1A 2E3W3", "Canada" },
{ "Zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzmabcdefghijklmnopqrstuvwxyzmabcdefghijklmnopqrs", "GivenNameZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzmabcdefghijklmnopqrstuvwxyzmabcdefghij",
"24arererere_rerere",
"121ere",
"new McGill College McGill College McGill College McGill Collegea",
" a Suite 32", "2r223",
"Montréal Long City Name On My So So It Is Split onto",
"", "Québec", "K1A 2E3", "Canada" }, };
String cpfn = m_busCompCCP.getFieldValue("CIC EAI Person Family Name"); // **report**
String cpgn = m_busCompCCP.getFieldValue("CIC EAI Person Given Name") ; //**report**
String ctdob = m_busCompCCP.getFieldValue("CIC EAI Person Textual Birth Date"); // **report**
try {
oAR.sCICPrimaryGivenName = cpgn;
oAR.sCICTextualDOB = ctdob;
// we have the data, add-it to the
// result set
// addonlythearchived ones; redundant check, should have been
// filtered already at the search spec BC
//if (status.equals(archivedENU) || status.equals(archivedFRA))
listArchiveLabel.add(oAR);
} catch (Exception exa) {
System.out
.println("Error adding a row from the result set:"
+ exa.toString());
}
bFound6 = m_busCompCCP.nextRecord();
}
bFound5 = m_busCompCACO.nextRecord();
}
bFound4 = m_busCompCPOC.nextRecord() ;
}
bFound3 = m_busCompCAMC.nextRecord();
}
bFound2= m_busCompAMAR.nextRecord();
\end{filecontents*}
\begin{landscape}
$$Retrieve\ methods$$
\begin{framed}
\lstinputlisting[style=MyJavaListStyle,
linerange={1-549},
firstnumber=1,
caption=file.java,
]{file.java}
\end{framed}
\end{landscape}
Continuation of the document.
\end{document}
Images:


hyphenatpackage is somehow the culprit, but you should investigate this yourself, and it would be nice if you reduced your example as Martin mentions above. – Torbjørn T. Feb 18 '15 at 12:21\begin{lstlisting}<code>\end{lstlisting}instead of\lstinputlisting{filename}, drop thesubfilesstuff, remove all figures, all text, all packages that doesn't affect this etc. We should be able to copy-paste the code into an empty file and compile it without modifications, and the PDF should show the problem. – Torbjørn T. Feb 18 '15 at 18:42try/catch, and makes the listing look better. – Torbjørn T. Sep 06 '15 at 10:49