Example usage for java.lang String concat

List of usage examples for java.lang String concat

Introduction

In this page you can find the example usage for java.lang String concat.

Prototype

public String concat(String str) 

Source Link

Document

Concatenates the specified string to the end of this string.

Usage

From source file:com.activecq.samples.slingresourceprovider.impl.SampleSlingResourceProvider.java

/**
 * Checks if this Resource Provider is willing to handle the resource path
 *
 * @param path/*w  w  w  . j a  v  a2  s .  c om*/
 * @return
 */
protected boolean accepts(String path) {
    for (String root : this.roots) {
        if (StringUtils.startsWith(path, root.concat("/"))) {
            return true;
        }
    }

    return false;
}

From source file:com.kn.calc.controller.VKAPIController.java

private JSONObject execute(String apiMethod, Param... params) throws IOException, JSONException {
    if (accessToken == null) {
        return new JSONObject();
    }/*from   w w w .j  a  va  2s .c  o  m*/

    String paramString = "?".concat("access_token=").concat(accessToken);
    if (params != null) {
        for (Param p : params) {
            paramString = paramString.concat("&").concat(p.getName()).concat("=").concat(p.getValue());
        }
    }

    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet method = new HttpGet(apiUrl.concat(apiMethod).concat(paramString));

    HttpResponse resp = client.execute(method);
    BufferedReader reader = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
    JSONObject json = new JSONObject(reader.readLine());
    reader.close();
    return json;
}

From source file:com.addthis.hydra.task.output.HDFSOutputWrapperFactory.java

/**
 * Opens a write stream for an HDFS output. Most of the complexity in this
 * method is related to determining the correct file name based on the given
 * {@code target} parameter.  If the file already exists and we are appending
 * to an existing file then we will rename that file and open up a new stream which
 * will append data to  that file.  If the file does not exist a new file is created
 * with a .tmp extension.  When the stream is closed the file will be renamed to remove
 * the .tmp extension/*from   w w w. j  a  v a  2  s .c o m*/
 *
 * @param target - the base file name of the target output stream
 * @param outputFlags - output flags setting various options about the output stream
 * @param streamEmitter - the emitter that can convert bundles into the desired byte arrays for output
 * @return a OutputWrapper which can be used to write bytes to the new stream
 * @throws IOException propagated from underlying components
 */
@Override
public OutputWrapper openWriteStream(String target, OutputStreamFlags outputFlags,
        OutputStreamEmitter streamEmitter) throws IOException {
    log.debug("[open] {}target={} hdfs", outputFlags, target);
    String modifiedTarget = getModifiedTarget(target, outputFlags);
    Path targetPath = new Path(dir, modifiedTarget);
    Path targetPathTmp = new Path(dir, modifiedTarget.concat(".tmp"));
    boolean exists = fileSystem.exists(targetPath);
    FSDataOutputStream outputStream;
    if (exists) {
        log.debug("[open.append]{}/ renaming to {}/{}", targetPath, targetPathTmp,
                fileSystem.exists(targetPathTmp));
        if (!fileSystem.rename(targetPath, targetPathTmp)) {
            throw new IOException("Unable to rename " + targetPath.toUri() + " to " + targetPathTmp.toUri());
        }
        outputStream = fileSystem.append(targetPathTmp);
    } else {
        outputStream = fileSystem.create(targetPathTmp, false);
    }
    OutputStream wrappedStream = wrapOutputStream(outputFlags, exists, outputStream);
    return new HDFSOutputWrapper(wrappedStream, streamEmitter, outputFlags.isCompress(),
            outputFlags.getCompressType(), target, targetPath, targetPathTmp, fileSystem);
}

From source file:com.adobe.acs.commons.util.InfoWriterTest.java

@Test
public void testTitle_Message() throws Exception {
    String expected = LS + StringUtils.repeat("-", 80) + LS + "The Title".concat(LS)
            + StringUtils.repeat("=", 80);

    iw.title("The Title");

    assertEquals(expected.concat(LS), iw.toString());
}

From source file:com.github.k0zka.contentcompress.ContentGzipMojo.java

void compress(final File directory, final String fileName) throws IOException {
    final File sourceFile = new File(directory, fileName);
    final File gzippedFile = new File(directory, fileName.concat(".gz"));
    if (gzippedFile.exists() && gzippedFile.lastModified() > sourceFile.lastModified()) {
        getLog().info("Skipped file " + sourceFile.getName() + " .gz is up to date");
        return;// ww w  . j av a2 s. com
    }
    final FileInputStream inputStream = new FileInputStream(sourceFile);
    final FileOutputStream fileStream = new FileOutputStream(gzippedFile);
    final GZIPOutputStream gzipStream = new GZIPOutputStream(fileStream);
    IOUtils.copy(inputStream, gzipStream);
    IOUtils.closeQuietly(inputStream);
    IOUtils.closeQuietly(gzipStream);
    IOUtils.closeQuietly(fileStream);
    final long sourceLength = sourceFile.length();
    final long gzipedLength = gzippedFile.length();
    if (sourceLength > gzipedLength) {
        getLog().info("Compressed file " + sourceFile.getName() + ". " + sourceLength + " -> " + gzipedLength);
    } else {
        getLog().info("Compressed file " + sourceFile.getName() + ". " + sourceLength + " -> " + gzipedLength
                + " removing, gzipped version is bigger");
        gzippedFile.delete();
    }
}

From source file:org.vaadin.spring.samples.mvp.ui.component.listener.LogoutLinkListener.java

@Override
public void buttonClick(ClickEvent event) {
    SecurityContextHolder.clearContext();
    HasComponents parent = event.getComponent().getParent();
    String contextPath = VaadinServlet.getCurrent().getServletContext().getContextPath();
    String urlMapping = env.getProperty("vaadin.servlet.urlMapping");
    String uiPath = urlMapping.substring(0, urlMapping.length() - 2);
    String location = contextPath.concat(uiPath);
    parent.getUI().getPage().setLocation(location);
}

From source file:com.codejumble.osbfa.attacker.CombinationFinder.java

private void createEndCharSet() {
    String tmp = "";
    for (String charSet : options) {
        tmp = tmp.concat(charSet);
    }/*from  ww w .j a v  a 2s.  co  m*/
    endCharSet = removeDuplicates(tmp);
    mainFrame.appendToMainLog("CombinationFinder was initialized with charset = " + getEndCharSet());
}

From source file:org.n52.series.db.dao.DatasetDao.java

private Criteria addIgnoreNonPublishedSeriesTo(Criteria criteria, String alias) {
    alias = prepareForConcatenation(alias);
    criteria.add(Restrictions.and(/*from   w ww. j a  v  a 2 s. c o  m*/
            Restrictions.and(Restrictions.isNotNull(alias.concat("firstValueAt")),
                    Restrictions.isNotNull(alias.concat("lastValueAt"))),
            Restrictions.eq(alias.concat("published"), true)));
    return criteria;
}

From source file:com.gitblit.auth.RedmineAuthProvider.java

private String getCurrentUserAsJson(String username, char[] password) throws IOException {
    if (testingJson != null) { // for testing
        return testingJson;
    }//ww w . jav a2 s .  com

    String url = this.settings.getString(Keys.realm.redmine.url, "");
    if (!url.endsWith("/")) {
        url = url.concat("/");
    }
    String apiUrl = url + "users/current.json";

    HttpURLConnection http;
    if (username == null) {
        // apikey authentication
        String apiKey = String.valueOf(password);
        http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, null, null);
        http.addRequestProperty("X-Redmine-API-Key", apiKey);
    } else {
        // username/password BASIC authentication
        http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, username, password);
    }
    http.setRequestMethod("GET");
    http.connect();
    InputStreamReader reader = new InputStreamReader(http.getInputStream());
    return IOUtils.toString(reader);
}

From source file:com.activecq.experiments.redis.impl.RedisResourceProviderImpl.java

/**
 * Checks if this Resource Provider is willing to handle the resource path
 *
 * @param path// ww w . j  ava 2 s. com
 * @return
 */
protected boolean accepts(String path) {
    for (String root : this.roots) {
        if (StringUtils.startsWith(path, root.concat("/")) || this.isRoot(path)) {
            return true;
        }
    }

    return false;
}