TeX - LaTeX Asked by user225381 on February 14, 2021
whose code is:
lstset{
inputencoding=utf8/latin1,
language=Java, % choose the language of the code
numbers=left, % where to put the line-numbers
stepnumber=1, % the step between two line-numbers.
numbersep=5pt, % how far the line-numbers are from the code
backgroundcolor=color{white}, % choose the background color. You must add usepackage{color}
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
keepspaces=true,
basicstyle=footnotesizettfamily,
commentstyle=color{greencomments},
keywordstyle=color{bluekeywords},
stringstyle=color{redstrings},
identifierstyle=color{types},
tabsize=2, % sets default tabsize to 2 spaces
captionpos=b, % sets the caption-position to bottom
breaklines=true, % sets automatic line breaking
breakatwhitespace=true, % sets if automatic breaks should only happen at whitespace
}
begin{lstlisting}
@Override
public boolean login(@NotNull Account account)
throws IOException, InterruptedException {
if (account.getEmail() == null)
return false;
if (account.getPassword() == null)
return false;
if (!respectPattern(String.valueOf(account.getPassword())))
return false;
String URL = getBaseUrl();
URL = URL.concat("/" + REPOSITORY);
URL = URL.concat("/admin-login");
final Map<String, Object> values = new HashMap<>();
values.put("key", account.getEmail());
values.put("password", String.valueOf(account.getPassword()));
ObjectMapper objectMapper = ObjectMapperCreator.getNewObjectMapper();
String requestBody = objectMapper.writeValueAsString(values);
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest
.newBuilder()
.uri(URI.create(URL))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = httpClient.send(request,
HttpResponse.BodyHandlers.ofString());
return response.statusCode() == 200 &&
setAuthenticationResultIntoAccount(response, account);
}
end{lstlisting}
How can I change colors to default Java ones and let auto-indent?
There is no "default Java coloring". You have to change colors manualy if you don't like them. Eg. try to switch
keywordstyle=color{black}
Or define your own color:
definecolor{mauve}{rgb}{0.3,0,0.3}
then
keywordstyle=color{mauve}
Answered by Tom Solid on February 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP