I have issue with \afterpage command and \lstlisting, it's add one blank page after beginning code listing, and after blank page is two of my command.
\appendix
\section*{APPENDIX A}
\newcommand\mycontinue{\noindent\makebox[\linewidth][r]{CONTINUE APPENDIX A}\afterpage{\mycontinue}}
\afterpage{\mycontinue}
\subsection*{Some title}
\lstinputlisting{code.java}
Answer for question for after page: https://tex.stackexchange.com/a/54292/14208