Example usage for java.io File separatorChar

List of usage examples for java.io File separatorChar

Introduction

In this page you can find the example usage for java.io File separatorChar.

Prototype

char separatorChar

To view the source code for java.io File separatorChar.

Click Source Link

Document

The system-dependent default name-separator character.

Usage

From source file:com.stimulus.archiva.presentation.DownloadMessageBean.java

@Override
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String fileName = request.getParameter("name");
    //String fileName = ((MessageBean)form).getOriginalMessageFileName();
    logger.debug("download original email {fileName='" + fileName + "'}");
    String agent = request.getHeader("USER-AGENT");
    if (null != agent && -1 != agent.indexOf("MSIE")) {
        String codedfilename = URLEncoder.encode(fileName, "UTF8");
        response.setContentType("application/x-download");
        response.setHeader("Content-Disposition", "attachment;filename=" + codedfilename);
    } else if (null != agent && -1 != agent.indexOf("Mozilla")) {
        String codedfilename = MimeUtility.encodeText(fileName, "UTF8", "B");
        response.setContentType("application/x-download");
        response.setHeader("Content-Disposition", "attachment;filename=" + codedfilename);
    } else {/*from w  ww  .  j av a  2s.c o  m*/
        response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
    }
    String contentType = "message/rfc822";
    //String filePath = ((MessageBean)form).getOriginalMessageFilePath();
    String filePath = Config.getFileSystem().getViewPath() + File.separatorChar + fileName;
    File file = new File(filePath);
    response.setContentLength((int) file.length());
    Config.getFileSystem().getTempFiles().markForDeletion(file);
    return new FileStreamInfo(contentType, file);
}

From source file:com.msopentech.odatajclient.engine.AbstractPropertyTest.java

private ODataProperty primitive() throws IOException {
    final InputStream input = getClass().getResourceAsStream(getVersion().name().toLowerCase()
            + File.separatorChar + "Customer_-10_CustomerId." + getSuffix(getFormat()));
    final ODataProperty property = getClient().getReader().readProperty(input, getFormat());
    assertNotNull(property);/* w w  w .j ava  2 s  .co m*/
    assertTrue(property.hasPrimitiveValue());
    assertTrue(-10 == property.getPrimitiveValue().<Integer>toCastValue());

    ODataProperty comparable;
    final ODataProperty written = getClient().getReader()
            .readProperty(getClient().getWriter().writeProperty(property, getFormat()), getFormat());
    if (getFormat() == ODataFormat.XML) {
        comparable = written;
    } else {
        // This is needed because type information gets lost with JSON serialization
        final ODataPrimitiveValue typedValue = getClient().getPrimitiveValueBuilder()
                .setType(EdmSimpleType.fromValue(property.getPrimitiveValue().getTypeName()))
                .setText(written.getPrimitiveValue().toString()).build();
        comparable = getClient().getObjectFactory().newPrimitiveProperty(written.getName(), typedValue);
    }

    assertEquals(property, comparable);

    return property;
}

From source file:de.thischwa.pmcms.view.context.object.tagtool.LinkTagTool.java

public LinkTagTool setHref(final String href) {
    link.init(href);//from w w  w  .j a  v  a2s  .  com
    isExternalLink = link.isExternal();
    String tempHref;
    if (isExternalLink)
        tempHref = href;
    else
        tempHref = href.replace(File.separatorChar, '/');
    return setAttribute("href", PathTool.encodePath(tempHref));
}

From source file:com.aurel.track.exchange.docx.importer.HTMLParser.java

private static String convertToFileURL(String filename) {
    String path = new File(filename).getAbsolutePath();
    if (File.separatorChar != '/') {
        path = path.replace(File.separatorChar, '/');
    }//from  w  w  w .  j ava2 s  .  c  om

    if (!path.startsWith("/")) {
        path = "/" + path;
    }
    return "file:" + path;
}

From source file:net.erdfelt.android.sdkfido.project.JavaPathValidator.java

private void validateJavaPackage(Dir sourceDir, String javapath) throws IOException {
    File javafile = sourceDir.getFile(javapath);
    FileReader reader = null;//from  ww  w .j  ava  2  s .c  om
    BufferedReader buf = null;
    try {
        reader = new FileReader(javafile);
        buf = new BufferedReader(reader);
        String line;
        String actualPackage;
        String expectedPackage = javapath.substring(0, javapath.length() - javafile.getName().length());
        expectedPackage = expectedPackage.replace(File.separatorChar, '.');
        Matcher mat;

        while ((line = buf.readLine()) != null) {
            mat = packagePat.matcher(line);
            if (mat.matches()) {
                actualPackage = mat.group(1);
                if (!StringUtils.equals(actualPackage, expectedPackage)) {
                    LOG.warning("" + javapath + " - NO MATCH TO " + expectedPackage);
                }
            }
        }
    } finally {
        IOUtils.closeQuietly(buf);
        IOUtils.closeQuietly(reader);
    }
}

From source file:com.bean.ImagenLogica.java

/**
 * Metodo encargado de la creacion de la ruta de la imagen de una determinada publicacion
 **//*from   w w w  .j  a v a 2 s .  co  m*/
public void crearRutaImgPublicacion() {

    servletContext = (ServletContext) contexto.getExternalContext().getContext();
    String ruta = "";
    //Ruta real hasta la carpeta uploads
    ruta = servletContext.getRealPath("/upload/");
    //Obtener el codigo del usuario de la sesion actual
    //este es utilizado para ubicar la carpeta que le eprtenece
    String codUsuario = String.valueOf(new SessionLogica().obtenerUsuarioSession().getCodUsuario());
    //Concatenamiento de directorios internos
    ruta += File.separatorChar + "img" + File.separatorChar + "post" + File.separatorChar + codUsuario
            + File.separatorChar + "all" + File.separatorChar;
    //Asignacion de la ruta creada
    this.rutaImgPublicacion = ruta;
}

From source file:com.googlecode.jgenhtml.JGenHtmlTestUtils.java

public static File getTestDir() {
    String tmpDir = FileUtils.getTempDirectoryPath();
    File testDir = new File(tmpDir + File.separatorChar + "jgenhtml");
    if (!testDir.exists()) {
        testDir.mkdirs();/*  w  w w  .  ja  v  a  2 s  .  c o  m*/
    }
    return testDir;
}

From source file:com.appleframework.jmx.connector.framework.ConnectorRegistry.java

@SuppressWarnings("deprecation")
private static ConnectorRegistry create(ApplicationConfig config) throws Exception {

    Map<String, String> paramValues = config.getParamValues();
    String appId = config.getApplicationId();
    String connectorId = (String) paramValues.get("connectorId");

    File file1 = new File(CoreUtils.getConnectorDir() + File.separatorChar + connectorId);

    URL[] urls = new URL[] { file1.toURL() };
    ClassLoader cl = ClassLoaderRepository.getClassLoader(urls, true);

    //URLClassLoader cl = new URLClassLoader(urls,
    //        ConnectorMBeanRegistry.class.getClassLoader());

    Registry.MODELER_MANIFEST = MBEANS_DESCRIPTOR;
    URL res = cl.getResource(MBEANS_DESCRIPTOR);

    logger.info("Application ID   : " + appId);
    logger.info("Connector Archive: " + file1.getAbsoluteFile());
    logger.info("MBean Descriptor : " + res.toString());

    //Thread.currentThread().setContextClassLoader(cl);
    //Registry.setUseContextClassLoader(true);

    ConnectorRegistry registry = new ConnectorRegistry();
    registry.loadMetadata(cl);/*from  ww  w .  j  av a 2 s . com*/

    String[] mbeans = registry.findManagedBeans();

    MBeanServer server = MBeanServerFactory.newMBeanServer(DOMAIN_CONNECTOR);

    for (int i = 0; i < mbeans.length; i++) {
        ManagedBean managed = registry.findManagedBean(mbeans[i]);
        String clsName = managed.getType();
        String domain = managed.getDomain();
        if (domain == null) {
            domain = DOMAIN_CONNECTOR;
        }

        Class<?> cls = Class.forName(clsName, true, cl);
        Object objMBean = null;

        // Use the factory method when it is defined.
        Method[] methods = cls.getMethods();
        for (Method method : methods) {
            if (method.getName().equals(FACTORY_METHOD) && Modifier.isStatic(method.getModifiers())) {
                objMBean = method.invoke(null);
                logger.info("Create MBean using factory method.");
                break;
            }
        }

        if (objMBean == null) {
            objMBean = cls.newInstance();
        }

        // Call the initialize method if the MBean extends ConnectorSupport class
        if (objMBean instanceof ConnectorSupport) {
            Method method = cls.getMethod("initialize", new Class[] { Map.class });
            Map<String, String> props = config.getParamValues();
            method.invoke(objMBean, new Object[] { props });
        }
        ModelMBean mm = managed.createMBean(objMBean);

        String beanObjName = domain + ":name=" + mbeans[i];
        server.registerMBean(mm, new ObjectName(beanObjName));
    }

    registry.setMBeanServer(server);
    entries.put(appId, registry);
    return registry;
}

From source file:com.github.rholder.esthree.cli.GetCommand.java

@Override
public void parse() {
    if (help) {/*from ww w  .  j a va 2 s.  c  om*/
        showUsage(commandMetadata);
        return;
    }

    if (firstNonNull(parameters, emptyList()).size() == 0) {
        showUsage(commandMetadata);
        throw new IllegalArgumentException("No arguments specified");
    }

    String target = parameters.get(0);
    bucket = S3PathUtils.getBucket(target);
    key = S3PathUtils.getPrefix(target);
    progress = progress == null;

    // TODO validate get params here
    if (parameters.size() > 1) {
        outputFile = new File(parameters.get(1));
    } else {
        // infer filename from file being fetched if unspecified
        String path = S3PathUtils.getPrefix(target);
        if (path == null) {
            throw new IllegalArgumentException("Could not determine target filename from " + target);
        }
        int index = path.lastIndexOf(File.separatorChar);
        int prefixLength = getPrefixLength(path);

        String fileName;
        if (index < prefixLength) {
            fileName = path.substring(prefixLength);
        } else {
            fileName = path.substring(index + 1);
        }
        outputFile = new File(fileName);
    }

    if (progress) {
        progressListener = new PrintingProgressListener(output, new TimeProvider());
    }
}

From source file:de.ailis.wlandsuite.PackGame.java

/**
 * @see de.ailis.wlandsuite.cli.PackProg#pack(java.io.File,
 *      java.io.OutputStream)/*from w  w  w  .ja  v  a 2 s.c  o m*/
 */

@Override
public void pack(File directory, OutputStream output) throws IOException {
    Game game;
    int mapNo, listNo;
    InputStream stream;
    File file;

    game = new Game();
    mapNo = 0;
    while (true) {
        file = new File(String.format("%s%cmap%02d.xml",
                new Object[] { directory.getPath(), File.separatorChar, mapNo }));
        if (!file.exists()) {
            break;
        }
        stream = new FileInputStream(file);
        try {
            log.info("Reading map " + mapNo);
            game.addMap(GameMap.readXml(stream));
        } finally {
            stream.close();
        }
        mapNo++;
    }

    file = new File(
            String.format("%s%csavegame.xml", new Object[] { directory.getPath(), File.separatorChar }));
    if (file.exists()) {
        stream = new FileInputStream(file);
        try {
            log.info("Reading savegame");
            game.setSavegame(Savegame.readXml(stream));
        } finally {
            stream.close();
        }
    }

    listNo = 0;
    while (true) {
        file = new File(String.format("%s%cshopitems%d.xml",
                new Object[] { directory.getPath(), File.separatorChar, listNo }));
        if (!file.exists()) {
            break;
        }
        stream = new FileInputStream(file);
        try {
            log.info("Reading shop list " + listNo);
            game.addShopItemList(ShopItemList.readXml(stream));
        } finally {
            stream.close();
        }
        listNo++;
    }

    if (this.disk == -1) {
        game.write(output);
    } else {
        game.write(output, this.disk);
    }
}