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:cienciaCelularMR.FernetMapper.java

@Override
public void map(KeyMcell key, Text value, Context output) throws IOException, InterruptedException {
    try {// w  w w.  ja  v  a 2  s .co m

        System.out.println("Entro al Map");
        System.out.println("Key del map fernet: " + key.toString());

        System.out.println("Fernet empezo a leer y guardar archivo .dat");
        try (FSDataInputStream fis = FileSystem.get(output.getConfiguration())
                .open(new Path(value.toString()))) {
            File archivo = new File("entradaFernet.dat");
            try (FileOutputStream fos = new FileOutputStream(archivo)) {
                byte[] buf = new byte[1024];
                int bytesRead;
                while ((bytesRead = fis.read(buf)) > 0) {
                    fos.write(buf, 0, bytesRead);
                    fos.flush();
                    output.progress();
                }
                fos.close();
                fis.close();
            }
        }

        System.out.println("Fernet termino de leer y guardar archivo .dat");
        Process process = new ProcessBuilder("fernet.exe", "--mode=" + key.getModoFernet().toString(),
                "--config=fernet.cfg", "entradaFernet.dat").start();

        InputStream is = process.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;

        System.out.println("Fernet is running");
        System.out.println("La key de mapper fernet es: " + key);
        String res = "";
        while ((line = br.readLine()) != null) {
            res = res.concat(line);
            output.progress();
        }

        if ("point".equals(key.getModoFernet().toString())) {
            System.out.println("Fernet es point");
            String salidaName = "salidaFernet-" + key.getIdUsuario() + "." + key.getSubIdUsuario() + ".txt";
            FSDataOutputStream fs = FileSystem.get(output.getConfiguration()).create(new Path(salidaName));

            File salidaFile = new File("out_point.txt");
            if (salidaFile.exists()) {

                byte[] buffer = readFileToByteArray(new File("out_point.txt"));
                FernetOutput salida = new FernetOutput();
                salida.setFileName(new Text("out_point.txt"));
                salida.setSubId(key.getIdUsuario());
                salida.setValue(new BytesWritable(buffer));
                output.write(key, salida);
            }
        } else {
            File dir = new File(".");
            FileFilter fileFilter = new WildcardFileFilter("multi_*.txt");
            File[] files = dir.listFiles(fileFilter);
            for (File file : files) {
                byte[] buffer = readFileToByteArray(new File(file.getName()));
                FernetOutput salida = new FernetOutput();
                salida.setFileName(new Text(file.getName()));
                salida.setSubId(key.getIdUsuario());
                salida.setValue(new BytesWritable(buffer));
                output.write(key, salida);
            }
        }

    } catch (Exception ex) {
        String salidaName = "errorMapper-" + key.getIdUsuario() + "." + key.getSubIdUsuario() + ".txt";
        FSDataOutputStream fs = FileSystem.get(output.getConfiguration()).create(new Path(salidaName));
        fs.write(new Byte("Error en Mapper FERnet"));
        fs.write(new Byte("\n"));
        fs.flush();
        fs.close();

        Logger.getLogger(FernetMapper.class.getName()).log(Level.SEVERE, null, ex);
        throw ex;
    }
}

From source file:com.erudika.para.storage.LocalFileStore.java

/**
 * Consturcts a new instance based on a given folder.
 * @param folder the folder to store files in
 */// w  ww.  j ava 2 s  . c  o m
public LocalFileStore(String folder) {
    if (StringUtils.endsWith(folder, File.separator)) {
        this.folder = folder;
    } else {
        this.folder = folder.concat(File.separator);
    }
}

From source file:edu.pucp.igc.piscosemanticsearch.Indexador.java

private String retomarTexto(String miArchivo) throws FileNotFoundException {
    //String rmRuta = "//Users//NuSs//Documents//workspaces//NetbeansWorkspace//SemanticSearch//src//main//resources//";
    //        FileInputStream fstream = new FileInputStream(rmRuta + miArchivo);
    //        DataInputStream = new DataInputStream(fstream);

    Scanner sc = new Scanner(new File(rmRuta + miArchivo));
    String strLinea = null;//  w ww . ja  va 2 s .  co m
    String texto = "";

    while (sc.hasNext()) {
        texto = texto.concat(sc.nextLine() + "\n");
    }
    return texto;
}

From source file:no.dusken.common.plugin.velocity.RenderPluginDirective.java

private void renderPlugin(InternalContextAdapter context, Writer writer, PluginContentMapping plugin) {
    Map<String, Object> currentContext = getCurrentContext(context);
    try {/*from   w w  w  .j a v a 2s .  c o  m*/
        ModelAndView mav = plugin.handleContentMapping(currentContext);
        String view = mav.getViewName();
        if (!view.endsWith(".vm")) {
            view = view.concat(".vm");
        }
        Template template = velocityEngine.getTemplate(view);

        template.merge(addToContext(context, mav.getModel()), writer);
    } catch (Exception e) {
        log.error("Error when merging template", e);
    }
}

From source file:com.spectralogic.ds3cli.views.cli.GetPhysicalPlacementWithFullDetailsView.java

private String renderBulkObjectList(final BulkObjectList bulkObjectList) {
    String output = "";

    for (int index = 0; index < bulkObjectList.getObjects().size(); index++) {
        output = output.concat(ASCIITable.getInstance().getTable(getBulkObjectHeaders(),
                formatBulkObjectList(bulkObjectList.getObjects().get(index))));

        if (bulkObjectList.getObjects().get(index).getPhysicalPlacement().getPools() != null) {
            output = output//from w ww .java2 s .  co m
                    .concat(ASCIITable.getInstance().getTable(getPoolsPlacementHeaders(), formatPoolsPlacement(
                            bulkObjectList.getObjects().get(index).getPhysicalPlacement().getPools())));
        }

        if (bulkObjectList.getObjects().get(index).getPhysicalPlacement().getTapes() != null) {
            output = output
                    .concat(ASCIITable.getInstance().getTable(getTapesPlacementHeaders(), formatTapesPlacement(
                            bulkObjectList.getObjects().get(index).getPhysicalPlacement().getTapes())));
        }
    }

    return output;
}

From source file:org.gvnix.service.roo.addon.addon.util.WsdlParserUtils.java

/**
 * Constructs a valid java package path from target namespace of root wsdl.
 * <p>/* w w  w .ja  v  a 2  s.c  om*/
 * Package ends with the package separator. Related package is different
 * when web service is rpc encoded or not.
 * </p>
 * 
 * @param root Root element of the wsdl
 * @return Equivalent java package or empty
 */
public static String getTargetNamespaceRelatedPackage(Element root) {

    Validate.notNull(root, ROOT_ELEMENT_REQUIRED);

    // Get the namespace attribute from root wsdl
    String namespace = getTargetNamespace(root);

    String pkg = getTargetNamespaceRelatedPackage(namespace, root).toLowerCase();
    pkg = pkg.replace('_', 'u');

    return pkg.concat(".");
}

From source file:com.tasktop.c2c.server.configuration.service.TemplateProcessingConfigurator.java

private File mapToTargetFile(File templateFile, ProjectServiceConfiguration configuration) {
    String templateFilePath = templateFile.getAbsolutePath().replace("C:", "");
    templateFilePath = templateFilePath.replace("\\", "/");
    int startOfBase = templateFilePath.indexOf(templateBaseLocation);
    if (startOfBase != 0) {
        throw new IllegalStateException();
    }/*from   w ww.  j  av  a  2 s  .c o m*/

    String fullTargetBaseLocation = targetBaseLocation;
    if (configuration.getProjectIdentifier() != null) {
        fullTargetBaseLocation = fullTargetBaseLocation.concat("/"
                + (perOrg ? configuration.getOrganizationIdentifier() : configuration.getProjectIdentifier()));
    }
    String filename = fullTargetBaseLocation + templateFilePath.substring(templateBaseLocation.length());
    return new File(filename);
}

From source file:filters.SaltingPasswordFilter.java

@Override
public String executePreProcessing(String request) {
    final Random r = new SecureRandom();
    byte[] salt = new byte[32];
    r.nextBytes(salt);/*from w ww  . ja v  a2 s . co m*/
    byte[] encodedSalt = Base64.encodeBase64(salt);
    String saltString = new String(encodedSalt);
    request = request.concat(saltString);
    return request;
}

From source file:com.erudika.para.security.CachedCsrfTokenRepository.java

/**
 * Saves a CSRF token in cache.//from   w ww  .ja v  a2 s.  c om
 * @param token the token
 * @param request HTTP request
 * @param response HTTP response
 */
public void saveToken(CsrfToken token, HttpServletRequest request, HttpServletResponse response) {
    String ident = getIdentifierFromCookie(request);
    if (ident != null) {
        String key = ident.concat(parameterName);
        token = loadToken(request);
        if (token == null) {
            token = generateToken(null);
            if (Config.isCacheEnabled()) {
                cache.put(Config.APP_NAME_NS, key, token, Config.SESSION_TIMEOUT_SEC);
            } else {
                localCache.put(key, new Object[] { token, System.currentTimeMillis() });
            }
        }
        storeTokenAsCookie(token, request, response);
    }
}

From source file:net.sf.jabref.gui.worker.SendAsEMailAction.java

@Override
public void run() {
    if (!Desktop.isDesktopSupported()) {
        message = Localization.lang("Error creating email");
        return;/*ww w .j  ava 2  s .c om*/
    }

    BasePanel panel = frame.getCurrentBasePanel();
    if (panel == null) {
        return;
    }
    if (panel.getSelectedEntries().isEmpty()) {
        message = Localization.lang("This operation requires one or more entries to be selected.");
        return;
    }

    StringWriter sw = new StringWriter();
    List<BibEntry> bes = panel.getSelectedEntries();

    // write the entries using sw, which is used later to form the email content
    BibEntryWriter bibtexEntryWriter = new BibEntryWriter(
            new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), true);

    for (BibEntry entry : bes) {
        try {
            bibtexEntryWriter.write(entry, sw, panel.getBibDatabaseContext().getMode());
        } catch (IOException e) {
            LOGGER.warn("Problem creating BibTeX file for mailing.", e);
        }
    }

    List<String> attachments = new ArrayList<>();

    // open folders is needed to indirectly support email programs, which cannot handle
    //   the unofficial "mailto:attachment" property
    boolean openFolders = JabRefPreferences.getInstance()
            .getBoolean(JabRefPreferences.OPEN_FOLDERS_OF_ATTACHED_FILES);

    List<File> fileList = FileUtil.getListOfLinkedFiles(bes,
            frame.getCurrentBasePanel().getBibDatabaseContext().getFileDirectory());
    for (File f : fileList) {
        attachments.add(f.getPath());
        if (openFolders) {
            try {
                JabRefDesktop.openFolderAndSelectFile(f.getAbsolutePath());
            } catch (IOException e) {
                LOGGER.debug("Cannot open file", e);
            }
        }
    }

    String mailTo = "?Body=".concat(sw.getBuffer().toString());
    mailTo = mailTo.concat("&Subject=");
    mailTo = mailTo.concat(JabRefPreferences.getInstance().get(JabRefPreferences.EMAIL_SUBJECT));
    for (String path : attachments) {
        mailTo = mailTo.concat("&Attachment=\"").concat(path);
        mailTo = mailTo.concat("\"");
    }

    URI uriMailTo;
    try {
        uriMailTo = new URI("mailto", mailTo, null);
    } catch (URISyntaxException e1) {
        message = Localization.lang("Error creating email");
        LOGGER.warn(message, e1);
        return;
    }

    Desktop desktop = Desktop.getDesktop();
    try {
        desktop.mail(uriMailTo);
    } catch (IOException e) {
        message = Localization.lang("Error creating email");
        LOGGER.warn(message, e);
        return;
    }

    message = String.format("%s: %d", Localization.lang("Entries added to an email"), bes.size());
}