Example usage for java.io File getAbsoluteFile

List of usage examples for java.io File getAbsoluteFile

Introduction

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

Prototype

public File getAbsoluteFile() 

Source Link

Document

Returns the absolute form of this abstract pathname.

Usage

From source file:io.stallion.dataAccess.db.SqlMigrationAction.java

public List<SqlMigration> getUserMigrations() {
    List<SqlMigration> migrations = list();
    File sqlDirectory = new File(settings().getTargetFolder() + "/sql");
    if (!sqlDirectory.isDirectory()) {
        Log.finer("Sql directory does not exist {0}", sqlDirectory.getAbsoluteFile());
        return migrations;
    }/*from  w ww.  j ava  2s  .  co  m*/
    Log.finer("Find sql files in {0}", sqlDirectory.getAbsolutePath());
    for (File file : sqlDirectory.listFiles()) {
        Log.finer("Scan file" + file.getAbsolutePath());
        if (!set("js", "sql").contains(FilenameUtils.getExtension(file.getAbsolutePath()))) {
            Log.finer("Extension is not .js or .sql {0}", file.getAbsolutePath());
            continue;
        }
        if (file.getName().startsWith(".") || file.getName().startsWith("#")) {
            Log.finer("File name starts with invalid character {0}", file.getName());
            continue;
        }
        if (!file.getName().contains("." + DB.instance().getDbImplementation().getName().toLowerCase() + ".")) {
            Log.finer("File name does not contain the name of the current database engine: \".{0}.\"",
                    DB.instance().getDbImplementation().getName().toLowerCase());
            continue;
        }
        if (!file.getName().contains("-")) {
            Log.finer("File name does not have version part {0}", file.getName());
            continue;
        }
        String versionString = StringUtils.stripStart(StringUtils.split(file.getName(), "-")[0], "0");
        if (!StringUtils.isNumeric(versionString)) {
            Log.finer("File name does not have numeric version part {0}", file.getName());
            continue;
        }
        Log.info("Load SQL file for migration: {0}", file.getName());

        migrations.add(new SqlMigration()
                .setVersionNumber(Integer.parseInt(StringUtils.stripStart(versionString, "0"))).setAppName("")
                .setFilename(file.getName()).setSource(FileUtils.readAllText(file)));
    }
    migrations.sort(new PropertyComparator<>("versionNumber"));
    return migrations;
}

From source file:architecture.ee.web.attachment.DefaultAttachmentManager.java

protected File getThumbnailFromCacheIfExist(Attachment attach, int width, int height) throws IOException {

    log.debug("thumbnail generation " + width + "x" + height);
    File dir = getAttachmentCacheDir();
    File file = new File(dir, toThumbnailFilename(attach, width, height));
    File originalFile = getAttachmentFromCacheIfExist(attach);
    log.debug("source: " + originalFile.getAbsoluteFile() + ", " + originalFile.length());
    log.debug("thumbnail:" + file.getAbsoluteFile());

    if (file.exists() && file.length() > 0) {
        attach.setThumbnailSize((int) file.length());
        return file;
    }/*from ww w  . j  a  v a  2 s.  c  o  m*/

    if (StringUtils.endsWithIgnoreCase(attach.getContentType(), "pdf")) {
        PDDocument document = PDDocument.load(originalFile);
        List<PDPage> pages = document.getDocumentCatalog().getAllPages();
        PDPage page = pages.get(0);
        BufferedImage image = page.convertToImage(BufferedImage.TYPE_INT_RGB, 72);
        ImageIO.write(Thumbnails.of(image).size(width, height).asBufferedImage(), "png", file);
        attach.setThumbnailSize((int) file.length());
        return file;
    } else if (StringUtils.startsWithIgnoreCase(attach.getContentType(), "image")) {
        BufferedImage originalImage = ImageIO.read(originalFile);
        if (originalImage.getHeight() < height || originalImage.getWidth() < width) {
            attach.setThumbnailSize(0);
            return originalFile;
        }
        BufferedImage thumbnail = Thumbnails.of(originalImage).size(width, height).asBufferedImage();
        ImageIO.write(thumbnail, "png", file);
        attach.setThumbnailSize((int) file.length());
        return file;
    }

    return null;
}

From source file:com.goodformobile.build.mobile.RIMPackageMojoTest.java

@Test
public void testExecuteOnProguardPreverifiedClasses() throws Exception {

    File projectDirectory = getRelativeFile("projects/maven-test-app-preverified-with-proguard/pom.xml")
            .getParentFile();/*from www  .  j av a 2s  .  c o m*/

    File workProjectDirectory = new File(getBasedir(), "target/temp/project");
    if (workProjectDirectory.exists()) {
        FileUtils.cleanDirectory(workProjectDirectory);
    }
    FileUtils.copyDirectory(projectDirectory, workProjectDirectory);

    RIMPackageMojo mojo = setupMojo();

    MavenProject project = getProject(mojo);

    setupProject(workProjectDirectory, project);

    mojo.execute();

    // Ensure a jad is generated.
    File targetDirectory = new File(workProjectDirectory, "target");
    File expectedJad = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "maven_test_app.jad");
    assertTrue("Unable to find generated jad: " + expectedJad.getAbsolutePath(), expectedJad.exists());

    // Ensure a cod file is generated.
    File expectedCod = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "maven_test_app.cod");
    assertTrue("Unable to find generated cod: " + expectedCod.getAbsolutePath(), expectedCod.exists());

}

From source file:com.splout.db.dnode.TestFetcher.java

@Test
public void testFileFetchingAndThrottling() throws IOException, URISyntaxException, InterruptedException {
    SploutConfiguration testConfig = SploutConfiguration.getTestConfig();
    testConfig.setProperty(FetcherProperties.TEMP_DIR, "tmp-dir-" + TestFetcher.class.getName());
    testConfig.setProperty(FetcherProperties.DOWNLOAD_BUFFER, 4);
    testConfig.setProperty(FetcherProperties.BYTES_PER_SEC_THROTTLE, 8);
    Fetcher fetcher = new Fetcher(testConfig);

    final String str = "This is what happens when you don't know what to write";

    File file = new File("tmp-" + TestFetcher.class.getName());
    Files.write(str.getBytes(), file);

    long startTime = System.currentTimeMillis();
    File f = fetcher.fetch(file.getAbsoluteFile().toURI().toString());
    long endTime = System.currentTimeMillis();

    double bytesPerSec = (str.getBytes().length / (double) (endTime - startTime)) * 1000;
    assertEquals(8, bytesPerSec, 0.5);/*w ww  .  j a va2 s  . c o  m*/

    assertTrue(f.exists());
    assertTrue(f.isDirectory());

    File file2 = new File(f, "tmp-" + TestFetcher.class.getName());
    assertTrue(file.exists());

    assertEquals(str, Files.toString(file2, Charset.defaultCharset()));

    file.delete();
    FileUtils.deleteDirectory(f);
}

From source file:localization.SplitterUI.java

public static void createMacroMyEsri() throws IOException {
    String content = "Option Explicit" + "\r\n" + "Sub Main" + "\r\n" + "Dim prj As PslProject" + "\r\n"
            + "Set prj = PSL.ActiveProject" + "\r\n" + "'Check whether we have open a project or not" + "\r\n"
            + "If prj Is Nothing Then" + "\r\n" + "MsgBox(\"No active Passolo project.\")" + "\r\n" + "Exit Sub"
            + "\r\n" + "End If" + "\r\n" + "Const ForWriting = 2" + "\r\n" + "Dim logFile As String" + "\r\n"
            + "logFile = Mid(prj.Location,1,InStrRev(prj.Location,\"\\\")) & prj.Name & \".log\"" + "\r\n"
            + "Dim objFSO, objFile, objFile2" + "\r\n"
            + "Set objFSO = CreateObject(\"Scripting.FileSystemObject\")" + "\r\n"
            + "If Dir(logFile) <> \"\" Then" + "\r\n" + "Set objFile2 = objFSO.OpenTextFile(logFile,ForWriting)"
            + "\r\n" + "Else" + "\r\n" + "Set objFile = objFSO.CreateTextFile(logFile,True)" + "\r\n"
            + "objFile.Close" + "\r\n" + "Set objFile2 = objFSO.OpenTextFile(logFile,ForWriting)" + "\r\n"
            + "End If" + "\r\n" + "Dim prjName As String" + "\r\n" + "prjName = prj.Name" + "\r\n"
            + "If (InStr(prj.Name,\"ECI\") > 0) Then" + "\r\n" + "ECI(prj,objFile2)" + "\r\n"
            + "ElseIf (InStr(prj.Name,\"AAC\") > 0) Then" + "\r\n" + "AAC(prj,objFile2)" + "\r\n"
            + "ElseIf (InStr(prj.Name,\"TOIN\") > 0) Then" + "\r\n" + "TOIN(prj,objFile2)" + "\r\n"
            + "ElseIf (InStr(prj.Name,\"LIOX\") > 0) Then" + "\r\n" + "LIOX(prj,objFile2)" + "\r\n" + "End If"
            + "\r\n" + "objFile2.Close" + "\r\n" + "End Sub" + "\r\n" + "Function ECI(prj,objFile2)" + "\r\n"
            + "Dim Lang As String" + "\r\n" + "Dim trn As PslTransList" + "\r\n" + "Dim i,j,h As Integer"
            + "\r\n" + "Dim LangNum As Integer" + "\r\n" + "Dim logoutput As String" + "\r\n"
            + "logoutput = \"Begin to process file \" & prj.Name" + "\r\n" + "objFile2.writeLine(logoutput)"
            + "\r\n" + "'Remove the language sets" + "\r\n"
            + "'The pointer of each string list of each language" + "\r\n"
            + "'It goes thought only one string list" + "\r\n" + "i = 0" + "\r\n" + "'The pointer of language"
            + "\r\n" + "j = 1" + "\r\n" + "h = 0" + "\r\n" + "LangNum = prj.Languages.Count" + "\r\n"
            + "For Each trn In prj.TransLists" + "\r\n" + "i = i + 1" + "\r\n" + "If ( i > LangNum) Then"
            + "\r\n" + "Exit For" + "\r\n" + "End If" + "\r\n" + "Lang = trn.Language.LangCode" + "\r\n"
            + "If ((StrComp(Lang,\"chs\") = 0) Or (StrComp(Lang,\"vit\") = 0) Or (StrComp(Lang, \"cht\") = 0) Or StrComp(Lang,\"tha\") = 0  ) Then"
            + "\r\n" + "j = j + 1" + "\r\n" + "h = h + 1" + "\r\n" + "Else" + "\r\n"
            + "logoutput = \"Removing language \" & Lang" + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n"
            + "prj.Languages.Remove(j)" + "\r\n" + "End If" + "\r\n" + "Next trn" + "\r\n"
            + "'Delete those source lists that are all translated and validated" + "\r\n"
            + "Dim delete As Boolean" + "\r\n" + "delete = True" + "\r\n"
            + "'The pointer of each string list of each language" + "\r\n" + "j = 0" + "\r\n"
            + "'The pointer of each string list" + "\r\n" + "i = 1" + "\r\n" + "For Each trn In prj.TransLists"
            + "\r\n" + "j = j + 1" + "\r\n" + "If(j > h) Then" + "\r\n" + "j = 1" + "\r\n" + "i = i + 1"
            + "\r\n" + "End If" + "\r\n" + "Dim k As Integer" + "\r\n" + "If (trn.TransRate <> 100) Then"
            + "\r\n" + "delete = False" + "\r\n" + "For k = 1 To trn.StringCount" + "\r\n"
            + "On Error Resume Next" + "\r\n" + "Dim tString As PslTransString" + "\r\n"
            + "Set tString = trn.String(k)" + "\r\n"
            + "If StrComp(tString.SourceText,tString.Text) <> 0 And tString.State(pslStateTranslated) = False And tString.State(pslStateReadOnly) = False Then"
            + "\r\n"
            + "logoutput = \"Find one source and translation are not identical in untranslated state. Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n"
            + "tString.Text = tString.SourceText" + "\r\n" + "End If" + "\r\n"
            + "If tString.State(pslStateTranslated) = True And tString.State(pslStateReadOnly) = False And tString.State(pslStateReview) = True And tString.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "trn.Save" + "\r\n" + "Else" + "\r\n"
            + "For k = 1 To trn.StringCount" + "\r\n" + "On Error Resume Next" + "\r\n"
            + "Dim tString1 As PslTransString" + "\r\n" + "Set tString1 = trn.String(k)" + "\r\n"
            + "If tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = False Then"
            + "\r\n" + "delete = False" + "\r\n"
            + "ElseIf tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString1.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "End If" + "\r\n"
            + "If (delete = True) And (j = h) Then" + "\r\n" + "prj.SourceLists.Remove(i)" + "\r\n"
            + "i = i - 1" + "\r\n" + "ElseIf (j = h) Then" + "\r\n" + "delete = True" + "\r\n" + "End If"
            + "\r\n" + "Next trn" + "\r\n" + "If prj.Languages.Count = 0 Or prj.SourceLists.Count = 0 Then"
            + "\r\n" + "Dim deleteFile As String" + "\r\n"
            + "deleteFile = prj.Location & \"\\\" + prj.Name & \".lpu\"" + "\r\n" + "prj.Close()" + "\r\n"
            + "Dim FileSys" + "\r\n" + "Set FileSys = CreateObject(\"Scripting.FileSystemObject\")" + "\r\n"
            + "FileSys.DeleteFile(deleteFile)" + "\r\n" + "End If" + "\r\n" + "End Function" + "\r\n"
            + "Function AAC(prj,objFile2)" + "\r\n" + "Dim Lang As String" + "\r\n" + "Dim trn As PslTransList"
            + "\r\n" + "Dim i,j,h As Integer" + "\r\n" + "Dim LangNum As Integer" + "\r\n"
            + "Dim logoutput As String" + "\r\n" + "logoutput = \"Begin to process file \" & prj.Name" + "\r\n"
            + "objFile2.writeLine(logoutput)" + "\r\n" + "'Remove the language sets" + "\r\n"
            + "'The pointer of each string list of each language" + "\r\n"
            + "'It goes thought only one string list" + "\r\n" + "i = 0" + "\r\n" + "h = 0" + "\r\n"
            + "'The pointer of language" + "\r\n" + "j = 1" + "\r\n" + "LangNum = prj.Languages.Count" + "\r\n"
            + "For Each trn In prj.TransLists" + "\r\n" + "i = i + 1" + "\r\n" + "If ( i > LangNum) Then"
            + "\r\n" + "Exit For" + "\r\n" + "End If" + "\r\n" + "Lang = trn.Language.LangCode" + "\r\n"
            + "If ((StrComp(Lang,\"sve\") = 0) Or (StrComp(Lang,\"fin\") = 0) Or (StrComp(Lang, \"dan\") = 0) Or (StrComp(Lang,\"nor\") = 0) Or (StrComp(Lang,\"plk\") = 0) Or (StrComp(Lang,\"nld\") = 0)) Then"
            + "\r\n" + "j = j + 1" + "\r\n" + "h = h + 1" + "\r\n" + "Else" + "\r\n" + "prj.Languages.Remove(j)"
            + "\r\n" + "End If" + "\r\n" + "Next trn" + "\r\n"
            + "'Delete those source lists that are all translated and validated" + "\r\n"
            + "Dim delete As Boolean" + "\r\n" + "delete = True" + "\r\n"
            + "'The pointer of each string list of each language" + "\r\n" + "j = 0" + "\r\n"
            + "'The pointer of each string list" + "\r\n" + "i = 1" + "\r\n" + "For Each trn In prj.TransLists"
            + "\r\n" + "j = j + 1" + "\r\n" + "If(j > h) Then" + "\r\n" + "j = 1" + "\r\n" + "i = i + 1"
            + "\r\n" + "End If" + "\r\n" + "Dim k As Integer" + "\r\n" + "If (trn.TransRate <> 100) Then"
            + "\r\n" + "delete = False" + "\r\n" + "For k = 1 To trn.StringCount" + "\r\n"
            + "On Error Resume Next" + "\r\n" + "Dim tString As PslTransString" + "\r\n"
            + "Set tString = trn.String(k)" + "\r\n"
            + "If StrComp(tString.SourceText,tString.Text) <> 0 And tString.State(pslStateTranslated) = False And tString.State(pslStateReadOnly) = False Then"
            + "\r\n"
            + "logoutput = \"Find one source and translation are not identical in untranslated state. Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n"
            + "tString.Text = tString.SourceText" + "\r\n" + "End If" + "\r\n"
            + "If tString.State(pslStateTranslated) = True And tString.State(pslStateReadOnly) = False And tString.State(pslStateReview) = True And tString.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "trn.Save" + "\r\n" + "Else"
            + "\r\n" + "For k = 1 To trn.StringCount" + "\r\n" + "On Error Resume Next" + "\r\n"
            + "Dim tString1 As PslTransString" + "\r\n" + "Set tString1 = trn.String(k)" + "\r\n"
            + "If tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = False Then"
            + "\r\n" + "delete = False" + "\r\n"
            + "ElseIf tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString1.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "End If" + "\r\n"
            + "If (delete = True) And (j = h) Then" + "\r\n" + "prj.SourceLists.Remove(i)" + "\r\n"
            + "i = i - 1" + "\r\n" + "ElseIf (j = h) Then" + "\r\n" + "delete = True" + "\r\n" + "End If"
            + "\r\n" + "Next trn" + "\r\n" + "If prj.Languages.Count = 0 Or prj.SourceLists.Count = 0 Then"
            + "\r\n" + "Dim deleteFile As String" + "\r\n"
            + "deleteFile = prj.Location & \"\\\" + prj.Name & \".lpu\"" + "\r\n" + "prj.Close()" + "\r\n"
            + "Dim FileSys" + "\r\n" + "Set FileSys = CreateObject(\"Scripting.FileSystemObject\")" + "\r\n"
            + "FileSys.DeleteFile(deleteFile)" + "\r\n" + "End If" + "\r\n" + "End Function" + "\r\n"
            + "Function TOIN(prj,objFile2)" + "\r\n" + "Dim Lang As String" + "\r\n" + "Dim trn As PslTransList"
            + "\r\n" + "Dim i,j,h As Integer" + "\r\n" + "Dim LangNum As Integer" + "\r\n"
            + "Dim logoutput As String" + "\r\n" + "logoutput = \"Begin to process file \" & prj.Name" + "\r\n"
            + "objFile2.writeLine(logoutput)" + "\r\n" + "i = 0" + "\r\n" + "j = 1" + "\r\n" + "h = 0" + "\r\n"
            + "LangNum = prj.Languages.Count" + "\r\n" + "For Each trn In prj.TransLists" + "\r\n" + "i = i + 1"
            + "\r\n" + "If ( i > LangNum) Then" + "\r\n" + "Exit For" + "\r\n" + "End If" + "\r\n"
            + "Lang = trn.Language.LangCode" + "\r\n"
            + "If ((StrComp(Lang,\"jpn\") = 0) Or (StrComp(Lang,\"kor\") = 0)) Then" + "\r\n" + "j = j + 1"
            + "\r\n" + "Else" + "\r\n" + "prj.Languages.Remove(j)" + "\r\n" + "End If" + "\r\n" + "Next trn"
            + "\r\n" + "'Delete those source lists that are all translated and validated" + "\r\n"
            + "Dim delete As Boolean" + "\r\n" + "delete = True" + "\r\n"
            + "'The pointer of each string list of each language" + "\r\n" + "j = 0" + "\r\n"
            + "'The pointer of each string list" + "\r\n" + "i = 1" + "\r\n" + "For Each trn In prj.TransLists"
            + "\r\n" + "j = j + 1" + "\r\n" + "If(j > h) Then" + "\r\n" + "j = 1" + "\r\n" + "i = i + 1"
            + "\r\n" + "End If" + "\r\n" + "Dim k As Integer" + "\r\n" + "If (trn.TransRate <> 100) Then"
            + "\r\n" + "delete = False" + "\r\n" + "For k = 1 To trn.StringCount" + "\r\n"
            + "On Error Resume Next" + "\r\n" + "Dim tString As PslTransString" + "\r\n"
            + "Set tString = trn.String(k)" + "\r\n"
            + "If StrComp(tString.SourceText,tString.Text) <> 0 And tString.State(pslStateTranslated) = False And tString.State(pslStateReadOnly) = False Then"
            + "\r\n"
            + "logoutput = \"Find one source and translation are not identical in untranslated state. Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n"
            + "tString.Text = tString.SourceText" + "\r\n" + "End If" + "\r\n"
            + "If tString.State(pslStateTranslated) = True And tString.State(pslStateReadOnly) = False And tString.State(pslStateReview) = True And tString.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "trn.Save" + "\r\n" + "Else"
            + "\r\n" + "For k = 1 To trn.StringCount" + "\r\n" + "On Error Resume Next" + "\r\n"
            + "Dim tString1 As PslTransString" + "\r\n" + "Set tString1 = trn.String(k)" + "\r\n"
            + "If tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = False Then"
            + "\r\n" + "delete = False" + "\r\n"
            + "ElseIf tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString1.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "End If" + "\r\n"
            + "If (delete = True) And (j = h) Then" + "\r\n" + "prj.SourceLists.Remove(i)" + "\r\n"
            + "i = i - 1" + "\r\n" + "ElseIf (j = h) Then" + "\r\n" + "delete = True" + "\r\n" + "End If"
            + "\r\n" + "Next trn" + "\r\n" + "If prj.Languages.Count = 0 Or prj.SourceLists.Count = 0 Then"
            + "\r\n" + "Dim deleteFile As String" + "\r\n"
            + "deleteFile = prj.Location & \"\\\" + prj.Name & \".lpu\"" + "\r\n" + "prj.Close()" + "\r\n"
            + "Dim FileSys" + "\r\n" + "Set FileSys = CreateObject(\"Scripting.FileSystemObject\")" + "\r\n"
            + "FileSys.DeleteFile(deleteFile)" + "\r\n" + "End If" + "\r\n" + "End Function" + "\r\n"
            + "Function LIOX(prj,objFile2)" + "\r\n" + "Dim Lang As String" + "\r\n" + "Dim trn As PslTransList"
            + "\r\n" + "Dim i,j,h As Integer" + "\r\n" + "Dim LangNum As Integer" + "\r\n"
            + "Dim logoutput As String" + "\r\n" + "logoutput = \"Begin to process file \" & prj.Name" + "\r\n"
            + "objFile2.writeLine(logoutput)" + "\r\n" + "i = 0" + "\r\n" + "j = 1" + "\r\n" + "h = 0" + "\r\n"
            + "LangNum = prj.Languages.Count" + "\r\n" + "For Each trn In prj.TransLists" + "\r\n" + "i = i + 1"
            + "\r\n" + "If ( i > LangNum) Then" + "\r\n" + "Exit For" + "\r\n" + "End If" + "\r\n"
            + "Lang = trn.Language.LangCode" + "\r\n"
            + "If ((StrComp(Lang,\"ita\") = 0) Or (StrComp(Lang,\"ptb\") = 0) Or (StrComp(Lang, \"rom\") = 0) Or (StrComp(Lang,\"ara\") = 0) Or (StrComp(Lang,\"csy\") = 0) Or (StrComp(Lang, \"deu\") = 0) Or (StrComp(Lang,\"fra\") = 0) Or (StrComp(Lang,\"heb\") = 0) Or (StrComp(Lang, \"rus\") = 0) Or (StrComp(Lang,\"trk\") = 0) Or (StrComp(Lang,\"ell\") = 0) Or (StrComp(Lang, \"esp\") = 0) Or (StrComp(Lang,\"eti\") = 0) Or (StrComp(Lang,\"lth\") = 0) Or (StrComp(Lang, \"lvi\") = 0) Or (StrComp(Lang, \"ptg\") = 0)) Then"
            + "\r\n" + "j = j + 1" + "\r\n" + "h = h + 1" + "\r\n" + "Else" + "\r\n" + "prj.Languages.Remove(j)"
            + "\r\n" + "End If" + "\r\n" + "Next trn" + "\r\n"
            + "'Delete those source lists that are all translated and validated" + "\r\n"
            + "Dim delete As Boolean" + "\r\n" + "delete = True" + "\r\n" + "j = 0" + "\r\n" + "i = 1" + "\r\n"
            + "For Each trn In prj.TransLists" + "\r\n" + "j = j + 1" + "\r\n" + "If(j > h) Then" + "\r\n"
            + "j = 1" + "\r\n" + "i = i + 1" + "\r\n" + "End If" + "\r\n" + "Dim k As Integer" + "\r\n"
            + "If (trn.TransRate <> 100) Then" + "\r\n" + "delete = False" + "\r\n"
            + "For k = 1 To trn.StringCount" + "\r\n" + "On Error Resume Next" + "\r\n"
            + "Dim tString As PslTransString" + "\r\n" + "Set tString = trn.String(k)" + "\r\n"
            + "If StrComp(tString.SourceText,tString.Text) <> 0 And tString.State(pslStateTranslated) = False And tString.State(pslStateReadOnly) = False Then"
            + "\r\n"
            + "logoutput = \"Find one source and translation are not identical in untranslated state. Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n"
            + "tString.Text = tString.SourceText" + "\r\n" + "End If" + "\r\n"
            + "If tString.State(pslStateTranslated) = True And tString.State(pslStateReadOnly) = False And tString.State(pslStateReview) = True And tString.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "trn.Save" + "\r\n" + "Else"
            + "\r\n" + "For k = 1 To trn.StringCount" + "\r\n" + "On Error Resume Next" + "\r\n"
            + "Dim tString1 As PslTransString" + "\r\n" + "Set tString1 = trn.String(k)" + "\r\n"
            + "If tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = False Then"
            + "\r\n" + "delete = False" + "\r\n"
            + "ElseIf tString1.State(pslStateTranslated) = True And tString1.State(pslStateReadOnly) = False And tString1.State(pslStateReview) = True And tString1.State(pslStateAutoTranslated) = True Then"
            + "\r\n" + "If tString1.State(pslStateLocked) = True Then" + "\r\n"
            + "logoutput = \"Find one green locked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "Else"
            + "\r\n"
            + "logoutput = \"Find one green unlocked string in Language: \" & trn.Language.LangCode & \" Number: \" & tString.Number & \" in Stringlist: \" & trn.Title"
            + "\r\n" + "objFile2.writeLine(logoutput)" + "\r\n" + "PSL.Output(logoutput)" + "\r\n" + "End If"
            + "\r\n" + "End If" + "\r\n" + "Next k" + "\r\n" + "End If" + "\r\n"
            + "If (delete = True) And (j = h) Then" + "\r\n" + "prj.SourceLists.Remove(i)" + "\r\n"
            + "i = i - 1" + "\r\n" + "ElseIf (j = h) Then" + "\r\n" + "delete = True" + "\r\n" + "End If"
            + "\r\n" + "Next trn" + "\r\n" + "If prj.Languages.Count = 0 Or prj.SourceLists.Count = 0 Then"
            + "\r\n" + "Dim deleteFile As String" + "\r\n"
            + "deleteFile = prj.Location & \"\\\" + prj.Name & \".lpu\"" + "\r\n" + "prj.Close()" + "\r\n"
            + "Dim FileSys" + "\r\n" + "Set FileSys = CreateObject(\"Scripting.FileSystemObject\")" + "\r\n"
            + "FileSys.DeleteFile(deleteFile)" + "\r\n" + "End If" + "\r\n" + "End Function" + "\r\n";
    File file = new File(MacroFolder + "\\PslLpuSplitter_v3.bas");

    // if file doesnt exists, then create it
    if (!file.exists()) {
        file.createNewFile();// w  w w  .  j  a  va  2s .  c  om
    }

    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(content);
    bw.close();
}

From source file:ch.vorburger.mariadb4j.DB.java

/**
 * Config Socket as absolute path. By default this is the case because DBConfigurationBuilder
 * creates the socket in /tmp, but if a user uses setSocket() he may give a relative location,
 * so we double check./*w w  w  . ja  v a2 s .co m*/
 * 
 * @return config.getSocket() as File getAbsolutePath()
 */
protected File getAbsoluteSocketFile() {
    String socket = configuration.getSocket();
    File socketFile = new File(socket);
    return socketFile.getAbsoluteFile();
}

From source file:com.blackducksoftware.integration.hub.cli.CLIDownloadService.java

private void unzip(File dir, final File zipFile, final IntLogger logger) throws IOException {
    // without getAbsoluteFile, getParentFile below seems to fail
    dir = dir.getAbsoluteFile();
    final ZipFile zip = new ZipFile(zipFile);
    final Enumeration<ZipEntry> entries = zip.getEntries();
    try {/*from w ww  .ja  va2 s  . c o m*/
        while (entries.hasMoreElements()) {
            final ZipEntry e = entries.nextElement();
            final File f = new File(dir, e.getName());
            if (e.isDirectory()) {
                f.mkdirs();
            } else {
                final File p = f.getParentFile();
                if (p != null) {
                    p.mkdirs();
                }
                final InputStream input = zip.getInputStream(e);
                try {
                    copyInputStreamToFile(input, f);
                } finally {
                    input.close();
                }
                f.setLastModified(e.getTime());
            }
        }
    } finally {
        zip.close();
    }
}

From source file:com.goodformobile.build.mobile.RIMPackageMojoTest.java

@Test
public void testExecuteOnBasicApplicationWithSingleDependency() throws Exception {

    File projectDirectory = getRelativeFile(
            "projects/app-with-dependency-preverified/BlackBerry_App_Descriptor.xml").getParentFile();
    File workProjectDirectory = setupCleanCopyOfProject(projectDirectory);

    RIMPackageMojo mojo = setupMojo();/*from   w ww. j  a  va2s .  co  m*/

    MavenProject project = getProject(mojo);

    setupProject(workProjectDirectory, project);
    project.setArtifactId("app-with-dependency");

    MavenProjectBasicStub projectStub = (MavenProjectBasicStub) project;
    projectStub.setBaseDir(workProjectDirectory);

    List<String> classPathElements = new ArrayList<String>();
    classPathElements.add(getRelativeFile("library_project_1.jar").getAbsolutePath());
    setVariableValueToObject(mojo, "classpathElements", classPathElements);

    mojo.execute();

    // Ensure a jad is generated.
    File targetDirectory = new File(workProjectDirectory, "target");
    File expectedJad = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "app_with_dependency.jad");
    assertTrue("Unable to find generated jad: " + expectedJad.getAbsolutePath(), expectedJad.exists());

    // Ensure a cod file is generated.
    File expectedCod = new File(targetDirectory.getAbsoluteFile() + File.separator + "deliverables"
            + File.separator + "app_with_dependency.cod");
    assertTrue("Unable to find generated cod: " + expectedCod.getAbsolutePath(), expectedCod.exists());
}

From source file:com.netflix.genie.web.resources.writers.DefaultDirectoryWriter.java

protected Directory getDirectory(final File directory, final String requestUrl, final boolean includeParent) {
    if (!directory.isDirectory()) {
        throw new IllegalArgumentException("Input directory is not a valid directory. Unable to continue.");
    }//from  w w  w .  j  av a2  s .co  m
    if (StringUtils.isBlank(requestUrl)) {
        throw new IllegalArgumentException("No request url entered. Unable to continue.");
    }
    final Directory dir = new Directory();

    if (includeParent) {
        final Entry parent = new Entry();
        String url = requestUrl;
        if (url.charAt(url.length() - 1) == '/') {
            url = url.substring(0, url.length() - 2);
        }
        // Rip off the last directory
        url = url.substring(0, url.lastIndexOf('/'));
        parent.setName("../");
        parent.setUrl(url);
        parent.setSize(0L);
        parent.setLastModified(new Date(directory.getParentFile().getAbsoluteFile().lastModified()));
        dir.setParent(parent);
    }

    final File[] files = directory.listFiles();
    dir.setDirectories(Lists.newArrayList());
    dir.setFiles(Lists.newArrayList());
    final String baseURL = requestUrl.endsWith("/") ? requestUrl : requestUrl + "/";
    if (files != null) {
        for (final File file : files) {
            final Entry entry = new Entry();
            entry.setLastModified(new Date(file.getAbsoluteFile().lastModified()));
            if (file.isDirectory()) {
                entry.setName(file.getName() + "/");
                entry.setUrl(baseURL + file.getName() + "/");
                entry.setSize(0L);
                dir.getDirectories().add(entry);
            } else {
                entry.setName(file.getName());
                entry.setUrl(baseURL + file.getName());
                entry.setSize(file.getAbsoluteFile().length());
                dir.getFiles().add(entry);
            }
        }
    }

    dir.getDirectories()
            .sort((final Entry entry1, final Entry entry2) -> entry1.getName().compareTo(entry2.getName()));

    dir.getFiles()
            .sort((final Entry entry1, final Entry entry2) -> entry1.getName().compareTo(entry2.getName()));

    return dir;
}

From source file:fr.norsys.asoape.anttask.GenerateAndroidClientTask.java

private Definition readDefinitionFrom(File definitionFile) throws BuildException {
    try {//from   w ww  . ja  v  a2  s  .co  m
        WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
        return reader.readWSDL(definitionFile.getAbsolutePath());
    } catch (WSDLException cause) {
        throw new BuildException(
                String.format("Unable to read definition file %s", definitionFile.getAbsoluteFile()), cause);
    }
}