# linewrap included Javafile with lstinputlisting

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{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))

} 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:

• It is much easier to help if you make your example a complete document that people can run locally and test answers. – David Carlisle Feb 12 '15 at 19:37
• – jub0bs Feb 13 '15 at 8:29
• Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – Reinstate Monica - M. Schröder Feb 16 '15 at 22:00
• After some testing it may look like the hyphenat package 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
• Hi Torbj\orn. Taking out the hypenat package works nearly perfect. The exceptions are when a line have too many spaces before wrapping. I'm adding a screen shot. – Iosif Tanasescu Feb 18 '15 at 16:58