Example usage for java.lang System lineSeparator

List of usage examples for java.lang System lineSeparator

Introduction

In this page you can find the example usage for java.lang System lineSeparator.

Prototype

String lineSeparator

To view the source code for java.lang System lineSeparator.

Click Source Link

Usage

From source file:io.github.bluemarlin.ui.searchtree.SearchFile.java

public SearchFile(File file) throws IOException {
    List<String> lines = FileUtils.readLines(file, "UTF-8");

    List<String> comments = lines.stream().filter(l -> l.startsWith("`")).collect(Collectors.toList());

    renderer = comments.stream().filter(c -> c.contains("$renderer")).findFirst().orElse("default");

    if ("default".equals(renderer)) {
        renderer = BluemarlinConfig.defaultRenderer();
    } else {//from w  w  w.  j a  v a 2  s.  c  o m
        renderer = StringUtils.substringAfter(renderer, "=");
    }

    int twentyMinsInMillis = 20 * 60 * 1000;
    long timeNowInMillis = (new Date()).getTime();
    String twentyMinsAgoInMillis = String.valueOf(timeNowInMillis - twentyMinsInMillis);
    jsonSearch = lines.stream().filter(l -> !l.startsWith("`"))
            .map(l -> l.replace("$DEFAULT_LEAGUE", BluemarlinConfig.defaultLeague()))
            .map(l -> l.replace("$TWENTY_MINS_AGO_IN_MILLISEC", twentyMinsAgoInMillis))
            .collect(Collectors.joining(System.lineSeparator()));
}

From source file:glluch.com.ontotaxoseeker.Terms.java

/**
 * Build a friendly representation of this object.
 * @return an String ready to print. /*w ww  .  j av a  2s  .com*/
 */
public String pretyPrint() {
    String res = "";
    Iterator iter = this.iterator();
    while (iter.hasNext()) {
        Term term = (Term) iter.next();
        res += term.getLema() + " -> " + this.get(term) + System.lineSeparator();
    }
    return res;
}

From source file:com.jslsolucoes.tagria.lib.grid.exporter.impl.CsvExporter.java

private void body(StringBuilder csv) {

    for (Row row : table.getRows()) {
        List<String> line = new ArrayList<>();
        for (Column column : row.getColumns()) {
            line.add(column.getContent());
        }//from  w w  w .  j  a  v a  2  s .c  om
        csv.append(StringUtils.join(line.toArray(), ",").concat(System.lineSeparator()));
    }
}

From source file:com.stratio.crossdata.sh.utils.ConsoleUtils.java

/**
 * Convert Result {@link com.stratio.crossdata.common.result.Result} structure to String.
 *
 * @param result {@link com.stratio.crossdata.common.result.Result} from execution.
 * @return String representing the result.
 *///from w ww.  ja  va2  s.  co m
public static String stringResult(Result result) {
    if (result instanceof ErrorResult) {
        ErrorResult error = ErrorResult.class.cast(result);
        StringBuilder sb = new StringBuilder("The operation for query ");
        sb.append(error.getQueryId()).append(" cannot be executed:").append(System.lineSeparator());
        sb.append(error.getErrorMessage()).append(System.lineSeparator());
        return sb.toString();
    } else if (result instanceof QueryResult) {
        QueryResult queryResult = (QueryResult) result;
        return stringQueryResult(queryResult);
    } else if (result instanceof CommandResult) {
        CommandResult commandResult = (CommandResult) result;
        Object objectResult = commandResult.getResult();
        return String.valueOf(objectResult);
    } else if (result instanceof ConnectResult) {
        ConnectResult connectResult = (ConnectResult) result;
        return String.valueOf("Connected with SessionId=" + connectResult.getSessionId());
    } else if (result instanceof MetadataResult) {
        MetadataResult metadataResult = (MetadataResult) result;
        return metadataResult.toString();
    } else if (result instanceof StorageResult) {
        StorageResult storageResult = (StorageResult) result;
        return storageResult.toString();
    } else if (result instanceof InProgressResult) {
        InProgressResult inProgressResult = (InProgressResult) result;
        return "Query " + inProgressResult.getQueryId() + " in progress";
    } else {
        return "Unknown result";
    }
}

From source file:net.thirdy.blackmarket.service.Ladder.java

public String leagueSizes() {
    String leagueSizes = ladderMapAllLeagues.entrySet().stream()
            .map(es -> String.format("%s - %d", es.getKey(), es.getValue().size()))
            .collect(Collectors.joining(System.lineSeparator()));
    return "Online players per league:" + System.lineSeparator() + leagueSizes;
}

From source file:com.sg.rest.filters.LoggerFilter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    if (!(request instanceof HttpServletRequest)) {
        LOGGER.error(NON_HTTP_REQUEST + System.lineSeparator() + request.getInputStream().toString());
        throw new RuntimeException(EXPECTING_AN_HTTP_REQUEST);
    }/*from w  w w  .j  av a 2s.  c  o  m*/

    HttpServletRequest httpRequest = (HttpServletRequest) request;

    StringBuilder sb = new StringBuilder();
    //General header
    sb.append(System.lineSeparator());
    sb.append(INCOMING_REQUEST);
    //Request url
    sb.append(System.lineSeparator());
    sb.append(REQUEST_URL);
    sb.append(httpRequest.getRequestURL());
    //Method
    sb.append(System.lineSeparator());
    sb.append(METHOD);
    sb.append(httpRequest.getMethod());
    //Parameters
    if (httpRequest.getParameterNames().hasMoreElements()) {
        sb.append(System.lineSeparator());
        sb.append(PARAMETERS);
        Enumeration enParams = httpRequest.getParameterNames();
        while (enParams.hasMoreElements()) {
            sb.append(System.lineSeparator());
            String paramName = (String) enParams.nextElement();
            sb.append(paramName);
            sb.append(" : ");
            sb.append(httpRequest.getParameter(paramName));
        }
    }
    //Attributes
    if (httpRequest.getAttributeNames().hasMoreElements()) {
        sb.append(System.lineSeparator());
        sb.append(ATTRIBUTES);
        Enumeration enAttribs = httpRequest.getAttributeNames();
        while (enAttribs.hasMoreElements()) {
            sb.append(System.lineSeparator());
            String attribName = (String) enAttribs.nextElement();
            sb.append(attribName);
            sb.append(" : ");
            sb.append(httpRequest.getAttribute(attribName));
        }
    }
    //Headers
    if (httpRequest.getHeaderNames().hasMoreElements()) {
        sb.append(System.lineSeparator());
        sb.append(HEADERS);
        Enumeration enHeaders = httpRequest.getHeaderNames();
        while (enHeaders.hasMoreElements()) {
            sb.append(System.lineSeparator());
            String headerName = (String) enHeaders.nextElement();
            sb.append(headerName);
            sb.append(" : ");
            sb.append(httpRequest.getHeader(headerName));
        }
    }
    //AuthType
    if (httpRequest.getAuthType() != null && !httpRequest.getAuthType().isEmpty()) {
        sb.append(System.lineSeparator());
        sb.append(AUTH_TYPE);
        sb.append(httpRequest.getAuthType());
    }
    //Cookies
    if (httpRequest.getCookies() != null && httpRequest.getCookies().length > 0) {
        sb.append(System.lineSeparator());
        sb.append(COOKIES);
        for (Cookie cookie : httpRequest.getCookies()) {
            sb.append(System.lineSeparator());
            sb.append(cookie.getName());
            sb.append(" : ");
            sb.append(cookie.getValue());
        }
    }
    //RemoteAddr
    if (httpRequest.getRemoteAddr() != null && !httpRequest.getRemoteAddr().isEmpty()) {
        sb.append(System.lineSeparator());
        sb.append(REMOTE_ADDR);
        sb.append(httpRequest.getRemoteAddr());
    }
    //RemoteHost
    if (httpRequest.getRemoteHost() != null && !httpRequest.getRemoteHost().isEmpty()) {
        sb.append(System.lineSeparator());
        sb.append(REMOTE_HOST);
        sb.append(httpRequest.getRemoteHost());
    }
    //User principal
    if (httpRequest.getUserPrincipal() != null) {
        if (httpRequest.getUserPrincipal().getName() != null
                && !httpRequest.getUserPrincipal().getName().isEmpty()) {
            sb.append(System.lineSeparator());
            sb.append(PRINCIPAL);
            sb.append(httpRequest.getUserPrincipal().getName());
        }
    }
    //Body
    ResettableStreamHttpServletRequest wrappedRequest = new ResettableStreamHttpServletRequest(
            (HttpServletRequest) request);
    String body = IOUtils.toString(wrappedRequest.getReader());
    if (body != null && !body.isEmpty()) {
        sb.append(System.lineSeparator());
        sb.append(BODY);
        sb.append(System.lineSeparator());
        sb.append(body);
    }
    wrappedRequest.resetInputStream();

    LOGGER.info(sb.toString());
    chain.doFilter(wrappedRequest, response);
}

From source file:de.tuttas.config.Config.java

/**
        //w ww  .j  av  a 2  s. c o m
 */

private Config() {
    BufferedReader br = null;
    try {
        String pathConfig = System.getProperty("catalina.base") + File.separator + "config.json";

        br = new BufferedReader(new FileReader(pathConfig));
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();
        while (line != null) {
            sb.append(line);
            sb.append(System.lineSeparator());
            line = br.readLine();
        }
        String conf = sb.toString();
        JSONParser parser = new JSONParser();
        JSONObject jo = (JSONObject) parser.parse(conf);
        debug = (boolean) jo.get("debug");

        auth = (boolean) jo.get("auth");
        IMAGE_FILE_PATH = (String) jo.get("IMAGE_FILE_PATH");
        ATEST_FILE_PATH = (String) jo.get("ATEST_FILE_PATH");
        TEMPLATE_FILE_PATH = (String) jo.get("TEMPLATE_FILE_PATH");
        Log.d("IMage_File_Path=" + IMAGE_FILE_PATH);
        JSONArray ja = (JSONArray) jo.get("adminusers");
        adminusers = new String[ja.size()];
        for (int i = 0; i < adminusers.length; i++) {
            adminusers[i] = (String) ja.get(i);
        }
        ja = (JSONArray) jo.get("verwaltung");
        verwaltung = new String[ja.size()];
        for (int i = 0; i < verwaltung.length; i++) {
            verwaltung[i] = (String) ja.get(i);
            Log.d("Setzte Verwaltung " + (String) ja.get(i));
        }

        AUTH_TOKE_TIMEOUT = (long) jo.get("AUTH_TOKE_TIMEOUT");

        // LDAP Konfiguration
        ldaphost = (String) jo.get("ldaphost");
        bindUser = (String) jo.get("binduser");
        bindPassword = (String) jo.get("bindpassword");
        userContext = (String) jo.get("context");

        // SMTP Server Konfiguration
        smtphost = (String) jo.get("smtphost");
        port = (String) jo.get("port");
        user = (String) jo.get("user");
        pass = (String) jo.get("pass");

        // Client Configuration
        clientConfig = (JSONObject) jo.get("clientConfig");
        clientConfig.put("VERSION", Config.VERSION);

    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex);
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
        Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ParseException ex) {
        ex.printStackTrace();
        Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            if (br != null)
                br.close();
        } catch (IOException ex) {
            Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:org.bonitasoft.web.designer.model.JacksonObjectMapperTest.java

@Test
public void should_format_json_when_using_pretty_print_on_object() throws Exception {
    SimpleObject object = new SimpleObject("id", "Vincent", 1);

    assertThat(objectMapper.prettyPrint(object)).isEqualTo("{" + System.lineSeparator() + "  \"id\" : \"id\","
            + System.lineSeparator() + "  \"name\" : \"Vincent\"," + System.lineSeparator() + "  \"number\" : 1"
            + System.lineSeparator() + "}");
}

From source file:sp.SAML1Controller.java

@RequestMapping(value = "/POST/ACS", method = RequestMethod.POST)
public ResponseEntity<String> handleSSOResponsePOST(HttpServletRequest servletRequest,
        HttpServletResponse servletResponse) throws Exception {

    MessageContext<SAMLObject> messageContext = decodeInboundMessageContextPost(servletRequest);

    if (!(messageContext.getMessage() instanceof Response)) {
        log.error("Inbound message was not a SAML 1 Response");
        return new ResponseEntity<>("Inbound message was not a SAML 1 Response", HttpStatus.BAD_REQUEST);
    }//  ww  w. j  av  a2  s. co  m

    Response response = (Response) messageContext.getMessage();
    Element responseElement = response.getDOM();
    String formattedMessage = SerializeSupport.prettyPrintXML(responseElement);
    log.trace("Returning response" + System.lineSeparator() + "{}", formattedMessage);

    //TODO instead of returning plain text via a ResponseEntity, add a JSP view that looks good

    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "text/plain");

    return new ResponseEntity<>(formattedMessage, headers, HttpStatus.OK);
}

From source file:com.amazonaws.util.awsclientgenerator.transform.C2jModelToGeneratorModelTransformer.java

String formatDocumentation(String documentation, int indentDepth) {
    if (documentation != null) {
        String tabString = "";
        for (int i = 0; i < indentDepth; ++i) {
            tabString += " ";
        }/*from  ww  w  .  j av a 2  s. co m*/
        String wrappedString = WordUtils.wrap(documentation, 80, System.lineSeparator() + tabString + "* ",
                false);
        return wrappedString.replace("/*", "/ *").replace("*/", "* /");
    }
    return null;
}