The solution in this answer already shows how to fine tune the line breaking of URL's by specifying \UrlBreaks, \UrlBigBreaks, and \UrlNoBreaks.
To get a carriage return symbol at breaking points, we specify the breaking points as \UrlSpecials, that include the symbol when a line break occurs there.
\usepackage{dingbat} % for \carriagereturn symbol
\newcommand{\urllb}{\discretionary{\carriagereturn}{}{}}
\renewcommand{\UrlBreaks}{} % no standard breaking points
\renewcommand{\UrlBigBreaks}{}
\renewcommand{\UrlSpecials}{\do\.{\mathchar`\.\urllb}%
\do\/{\mathchar`\/\urllb}%
\do\@{\mathchar`\@\urllb}%
\do\\{\mathchar`\\\urllb}%
\do\-{\mathchar`\-\urllb}%
\do\#{\mathchar`\#\urllb}}% and so on
To specify breaking points by hand we use a symbol that hopefully won't occur in any URL like a star *, and make it a break URL's like the above symbols, but vanishing from the string:
\renewcommand{\UrlSpecials}{\do\*{\urllb}}
In order to have correct links with this solution the star needs to be filtered out from the link, too. We use the gorgeous solution of Qrrbrbirlbel:
\makeatletter
\def\strip@star#1*#2\@strip@star{%
\expandafter\def\expandafter\strip@star@result\expandafter{\strip@star@result#1}%
\if\relax\detokenize{#2}\relax\else
\def\strip@star@temp{#2}%
\expandafter\expandafter\expandafter\strip@star\expandafter\strip@star@temp
\expandafter\@strip@star
\fi
}
\patchcmd{\hyper@linkurl}{\Hy@pstringdef\Hy@pstringURI{#2}}{%
\def\strip@star@result{}%
\expandafter\strip@star#2*\@strip@star
\Hy@pstringdef\Hy@pstringURI{\strip@star@result}%
}{}{}
\makeatother
Of course, both solutions can be mixed, i.e., we can specify the normal breaking points as \UrlSpecials, as well as the star for additional hand made breaking points.
Complete code:
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@misc{reference,
title = {{Some dummy title in bib.}},
howpublished = {\url{http://docs.*oracle.com/*javase/*1.5.0/*docs/*rel*notes/*fea*tures.html#*concur*rency}},
note = {Last access: 12.03.2013},
}
\end{filecontents*}
\documentclass[10pt,a4paper]{article}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
\usepackage[margin=2.5cm]{geometry}
\usepackage{etoolbox}
\usepackage{dingbat} % for \carriagereturn symbol
\newcommand{\urllb}{\discretionary{\carriagereturn}{}{}}
%% original breaking points of url package
% \def\UrlBreaks{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\;\do\>\do\]%
% \do\)\do\,\do\?\do\'\do+\do\=\do\#}%
% \def\UrlBigBreaks{\do\:\do@url@hyp}%
\makeatletter
\g@addto@macro{\UrlNoBreaks}{\do\.} % do not break after dot '.'
\makeatother
\renewcommand{\UrlBreaks}{} % no standard breaking points
\renewcommand{\UrlBigBreaks}{}
\renewcommand{\UrlSpecials}{\do\_{\mathchar`\_\urllb}%
\do\/{\mathchar`\/\urllb}%
\do\@{\mathchar`\@\urllb}%
\do\\{\mathchar`\\\urllb}%
\do\-{\mathchar`\-\urllb}%
\do\#{\mathchar`\#\urllb}}% and so on
% \renewcommand{\UrlSpecials}{\do\*{\urllb}}
%% solution of Qrrbrbirlbel, see https://tex.stackexchange.com/q/103870/21591
\makeatletter
\def\strip@star#1*#2\@strip@star{%
\expandafter\def\expandafter\strip@star@result\expandafter{\strip@star@result#1}%
\if\relax\detokenize{#2}\relax\else
\def\strip@star@temp{#2}%
\expandafter\expandafter\expandafter\strip@star\expandafter\strip@star@temp
\expandafter\@strip@star
\fi
}
\patchcmd{\hyper@linkurl}{\Hy@pstringdef\Hy@pstringURI{#2}}{%
\def\strip@star@result{}%
\expandafter\strip@star#2*\@strip@star
\Hy@pstringdef\Hy@pstringURI{\strip@star@result}%
}{}{}
\makeatother
\parindent0pt
\begin{document}
This is text with \cite{reference}.
Automatic breaking with carriage return symbol:
Text text text text text text text
\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html#concurrency}
Text text text text text text text text
\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html#concurrency}
Text text text text text text text text text
\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html#concurrency}
Text text text text text text text text text text
\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html#concurrency}
Text text text text text text text text text text text
\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html#concurrency}
Text text text text text text text text text text text text
\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html#concurrency}
\bigskip
\renewcommand{\UrlSpecials}{\do\*{\urllb}}
Hand tuned URL breaking:
Text text text text text text text text
\url{http://docs.*oracle.com/*javase/*1.5.0/*docs/*rel*notes/*fea*tures.html#concur*rency}
Text text text text text text text text text
\url{http://docs.*oracle.com/*javase/*1.5.0/*docs/*rel*notes/*fea*tures.html#concur*rency}
Text text text text text text text text text text
\url{http://docs.*oracle.com/*javase/*1.5.0/*docs/*rel*notes/*fea*tures.html#concur*rency}
Text text text text text text text text text text text
\url{http://docs.*oracle.com/*javase/*1.5.0/*docs/*rel*notes/*fea*tures.html#concur*rency}
Text text text text text text text text text text text text
\url{http://docs.*oracle.com/*javase/*1.5.0/*docs/*rel*notes/*fea*tures.html#concur*rency}
\bibliographystyle{unsrt}
\bibliography{faramir2}
\end{document}
yields

All hail to Qrrbrbirlbel for the hard part.
A4and margins of2.5cm, it's perfectly sound to break the long URL afterfeatures., as the resulting line is neither overfull nor underfull (i.e., no big whitespaces). If you were to change the margins to4cm, say, you'd get a line break after/docs/. – Mico Mar 12 '13 at 18:48