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:de.ailis.wlandsuite.UnpackHtds.java

/**
 * @see de.ailis.wlandsuite.cli.UnpackProg#unpack(java.io.InputStream,
 *      java.io.File)/*from  ww  w. j  av a  2  s  .c o m*/
 */

@Override
public void unpack(InputStream input, File directory) throws IOException {
    Htds htds;
    List<HtdsTileset> tilesets;
    int tilesetNo, tileNo;
    File bankDir;

    htds = Htds.read(input, this.width, this.height);
    tilesets = htds.getTilesets();
    tilesetNo = 0;
    for (HtdsTileset tileset : tilesets) {
        log.info("Writing tileset " + tilesetNo);
        bankDir = new File(
                String.format("%s%c%03d", new Object[] { directory.getPath(), File.separatorChar, tilesetNo }));
        bankDir.mkdirs();
        tileNo = 0;
        for (Pic tile : tileset.getTiles()) {
            ImageIO.write(tile, "PNG", new File(String.format("%s%c%03d.png",
                    new Object[] { bankDir.getPath(), File.separatorChar, tileNo })));
            tileNo++;
        }
        tilesetNo++;
    }
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtils.java

/**
 * Transforms a package name to a relative location on the file system.
 * //  ww w .j  a v  a  2s .com
 * @param packageName the java package name
 * @return the relative location on file system (with ending file
 *         separator). Empty string if package name is null.
 */
public static String packageToLocation(String packageName) {
    if (packageName == null || packageName.trim().length() == 0) {
        return "";
    }
    String location = packageName.replace('.', File.separatorChar);
    if (location.charAt(location.length() - 1) != File.separatorChar) {
        location += File.separatorChar;
    }
    return location;
}

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

@Override
public void parse() {
    if (help) {//from   w ww. j  a  va 2 s  . com
        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-multi 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:com.msopentech.odatajclient.testservice.utils.Commons.java

public static String getLinksPath(final ODataVersion version, final String basePath, final String linkName,
        final Accept accept) throws IOException {
    try {// www .  java  2 s .  c  o  m
        return FSManager.instance(version)
                .getAbsolutePath(basePath + LINKS_FILE_PATH + File.separatorChar + linkName, accept);
    } catch (Exception e) {
        throw new IOException(e);
    }
}

From source file:es.udc.gii.common.eaf.log.LogTool.java

private void createFile(String folder, String file_name) {

    File new_file;
    File new_folder;

    try {//from   w w  w.j av a 2  s .co  m
        if (!folder.endsWith(String.valueOf(File.separatorChar))) {
            folder += File.separatorChar;
        }

        new_folder = new File(folder);
        new_folder.mkdirs();
        new_file = new File(folder + file_name);

        this.log = new PrintStream(new_file, "UTF-8");
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    }

}

From source file:com.qcadoo.model.internal.file.FileServiceImpl.java

@Override
public String getName(final String path) {
    if (!StringUtils.hasText(path)) {
        return null;
    }// ww  w  .  ja v  a2s  .c  om
    return path.substring(path.lastIndexOf(File.separatorChar) + 1);
}

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

/**
 * @see de.ailis.wlandsuite.cli.UnpackProg#unpack(java.io.InputStream,
 *      java.io.File)/*w w w.jav a 2s .  co  m*/
 */

@Override
public void unpack(InputStream input, File directory) throws IOException {
    int picNo;
    int frameNo;
    int frameSetNo;
    File picDirectory;
    File setDirectory;
    PrintWriter writer;
    Pics pics;

    pics = Pics.read(input, this.width);
    picNo = 0;
    for (PicsAnimation pic : pics.getAnimations()) {
        log.info("Writing pic " + picNo);
        picDirectory = new File(
                String.format("%s%c%03d", new Object[] { directory.getPath(), File.separatorChar, picNo }));
        picDirectory.mkdirs();

        // Write the base frame
        ImageIO.write(pic.getBaseFrame(), "PNG",
                new File(picDirectory.getPath() + File.separatorChar + "000.png"));

        frameSetNo = 0;
        for (PicsAnimationFrameSet set : pic.getFrameSets()) {
            setDirectory = new File(String.format("%s%c%03d",
                    new Object[] { picDirectory.getPath(), File.separatorChar, frameSetNo }));
            setDirectory.mkdirs();

            frameNo = 0;
            for (BufferedImage frame : set.getFrames()) {
                ImageIO.write(frame, "PNG", new File(String.format("%s%c%03d.png",
                        new Object[] { setDirectory.getPath(), File.separatorChar, frameNo + 1 })));

                frameNo++;
            }
            frameSetNo++;

            // Write the animation data
            writer = new PrintWriter(new FileWriter(new File(String.format("%s%canimation.txt",
                    new Object[] { setDirectory.getPath(), File.separatorChar }))));
            try {
                writer.println("# First number is the delay value (0-254)");
                writer.println("# Second number is the frame to display (000 = Base frame)");
                writer.println();
                for (PicsAnimationInstruction instruction : set.getInstructions()) {
                    writer.println(String.format("%3d %03d",
                            new Object[] { instruction.getDelay(), instruction.getFrame() }));
                }
            } finally {
                writer.close();
            }
        }
        picNo++;
    }
}

From source file:com.swiftcorp.portal.report.service.ReportServiceImpl.java

public String generateMPRReport(int year) throws Exception {
    // get the mother record
    //MotherDeathRecord motherDeathRecord = this.getMotherDeathRecord ( year );
    Calendar calendarLastDate = CalendarUtils.getLastdayOfMonth(12, year);
    Calendar calendarFirstDate = CalendarUtils.getFirstdayOfMonth(1, year);
    Date fromDate = calendarFirstDate.getTime();
    Date toDate = calendarFirstDate.getTime();

    List<BeneficiaryDeathRecord> beneficiaryDeathRecords = mpReportDAO.getBeneficiaryDeathDTOList(fromDate,
            toDate);//from   w ww  . ja v  a2 s.c  om
    /*Map beans = new HashMap ();
    beans.put ( "motherDeathRecord", motherDeathRecord );
    */
    Map<String, List<BeneficiaryDeathRecord>> beans = new HashMap<String, List<BeneficiaryDeathRecord>>();
    beans.put("mReport", beneficiaryDeathRecords);

    String templateFilePath = this.reportTemplateDir + File.separatorChar + MPR_REPORT_TEMPLATE_NAME;
    String reportFullFilePath = ReportUtils.getDeathReportFileName(reportDir, "mprReport", year);

    // now generate report
    ReportUtils.generateReport(templateFilePath, beans, reportFullFilePath);

    // return the path
    return reportFullFilePath;
}

From source file:edu.stanford.muse.launcher.Main.java

public static WebAppContext deployWarAt(String warName, String path) throws IOException {
    // extract the war to tmpdir
    final URL warUrl = Main.class.getClassLoader().getResource(warName);
    if (warUrl == null) {
        System.err.println("Sorry! Unable to locate file on classpath: " + warName);
        return null;
    }//from  w  ww. java 2s  . c om
    InputStream is = warUrl.openStream();
    String tmp = System.getProperty("java.io.tmpdir");
    String file = tmp + File.separatorChar + warName;
    copy_stream_to_file(is, file);

    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath(path);
    webapp.setWar(file);
    webapp.setExtractWAR(true);

    return webapp;
}

From source file:org.ambraproject.admin.action.DeleteArticleActionTest.java

@Test
public void testDelete() throws Exception {
    Article article = new Article();
    article.setDoi("info:doi/10.1371/journal.pone.00000");
    dummyDataStore.store(article);//from w w  w .j  a  v a 2 s .  c o  m

    //make some files in the filestore to see if they get deleted
    File homeDir = new File(filestoreDir + File.separatorChar + "10.1371", "pone.00000");
    homeDir.mkdirs();
    homeDir.deleteOnExit();
    File xml = new File(homeDir, "pone.00000.xml");
    if (!xml.exists()) {
        xml.createNewFile();
        xml.deleteOnExit();
    }

    //make a file in the ingested folder to see that it gets moved back to ingest
    File zip = new File(ingestedDir, "pone.00000.zip");
    if (!zip.exists()) {
        zip.createNewFile();
        zip.deleteOnExit();
    }
    File crossrefFile = new File(ingestedDir, "info_doi_10_1371_journal_pone_00000.xml");
    if (!crossrefFile.exists()) {
        crossrefFile.createNewFile();
        crossrefFile.deleteOnExit();
    }
    File ingestZip = new File(ingestDir, zip.getName());
    ingestZip.deleteOnExit();

    //add some annotations to the article to see that they get deleted
    UserProfile creator = new UserProfile("email@DeleteArticleAction.org", "displayNameDeleteArticleAction",
            "pass");
    dummyDataStore.store(creator);
    Annotation comment = new Annotation(creator, AnnotationType.COMMENT, article.getID());
    dummyDataStore.store(comment);
    Annotation reply = new Annotation(creator, AnnotationType.REPLY, article.getID());
    reply.setParentID(comment.getID());
    dummyDataStore.store(reply);

    action.setRequest(getDefaultRequestAttributes()); //somehow the request is getting overwritten when all the tests are run together...
    action.setArticle(article.getDoi());
    String result = action.deleteArticle();

    assertEquals(result, Action.SUCCESS, "action didn't return success");
    assertEquals(action.getActionErrors().size(), 0,
            "Action returned error messages: " + StringUtils.join(action.getActionErrors(), ","));
    assertEquals(action.getActionMessages().size(), 1, "Action didn't return message indicating success");

    //check that the article got deleted from the database
    assertNull(dummyDataStore.get(Annotation.class, reply.getID()),
            "Reply to a comment on the article didn't get deleted from the database");
    assertNull(dummyDataStore.get(Annotation.class, comment.getID()),
            "Comment on the article didn't get deleted from the database");
    assertNull(dummyDataStore.get(Article.class, article.getID()),
            "Article didn't get deleted from the database");

    //check that the file got deleted from the filestore
    assertEquals(homeDir.list(), new String[0], "files didn't get deleted from the filestore");
    assertFalse(zip.exists(), "zip in the ingested directory didn't get deleted");
    assertFalse(crossrefFile.exists(), "crossref file didn't get deleted");
    assertTrue(ingestZip.exists(), "ingested file didn't get added to the ingest directory");
}