Example usage for java.io BufferedWriter close

List of usage examples for java.io BufferedWriter close

Introduction

In this page you can find the example usage for java.io BufferedWriter close.

Prototype

@SuppressWarnings("try")
    public void close() throws IOException 

Source Link

Usage

From source file:au.org.ala.delta.intkey.model.StartupUtils.java

/**
 * Save a copy of a dataset that was opened from a remote location
 * /*www .  j  av  a2s. com*/
 * @param context
 *            Intkey context
 * @param saveDir
 *            Directory in which to save a copy of the dataset
 * @return A copy of the JNLP-style dataset startup file to use to open the
 *         saved copy of the dataset.
 * @throws IOException
 *             If saving to disk failed.
 */
public static File saveRemoteDataset(IntkeyContext context, File saveDir) throws IOException {
    StartupFileData startupFileData = context.getStartupFileData();
    File datasetZip = startupFileData.getDataFileLocalCopy();

    // Copy the zipped dataset as downloaded from the web
    // FileUtils.copyFileToDirectory(datasetZip, saveDir);

    // Copy the zipped dataset as downloaded from the web
    // Use utility method to avoid overwriting existing files with the same
    // name
    File copyZipFile = Utils.getSaveFileForDirectory(saveDir, datasetZip.getName());
    FileUtils.copyFile(datasetZip, copyZipFile);

    // Write a new .ink file
    // Use utility method to avoid overwriting existing files with the same
    // name
    File newInkFile = Utils.getSaveFileForDirectory(saveDir,
            FilenameUtils.getName(startupFileData.getInkFileLocation().getFile()));

    FileWriter fw = new FileWriter(newInkFile);
    BufferedWriter bufFW = new BufferedWriter(fw);

    bufFW.append(INIT_FILE_INK_FILE_KEYWORD);
    bufFW.append("=");
    bufFW.append(newInkFile.toURI().toURL().toString());
    bufFW.append("\n");

    bufFW.append(INIT_FILE_DATA_FILE_KEYWORD);
    bufFW.append("=");
    bufFW.append(copyZipFile.toURI().toURL().toString());
    bufFW.append("\n");

    bufFW.append(INIT_FILE_INITIALIZATION_FILE_KEYWORD);
    bufFW.append("=");
    bufFW.append(startupFileData.getInitializationFileLocation());
    bufFW.append("\n");

    String imagePath = startupFileData.getImagePath();
    if (imagePath != null) {
        bufFW.append(INIT_FILE_IMAGE_PATH_KEYWORD);
        bufFW.append("=");
        bufFW.append(imagePath);
        bufFW.append("\n");
    }

    String infoPath = startupFileData.getInfoPath();
    if (infoPath != null) {
        bufFW.append(INIT_FILE_INFO_PATH_KEYWORD);
        bufFW.append("=");
        bufFW.append(infoPath);
        bufFW.append("\n");
    }

    bufFW.flush();
    bufFW.close();

    return newInkFile;
}

From source file:model.settings.ReadSettings.java

/**
 * Set up paint as program in OSX.//from   w  w w.  java  2  s.  c o  m
 */
private static void installOSX() {

    try {

        final String name = "paint";
        final String app_name = "Paint.app";
        /*
         * STEP 1:   Create files and folders for the info.plist
         */
        final String filePath = "/Applications/" + app_name + "/Contents/";
        final String fileName = "Info.plist";
        final String fileContent = "" + "<dict>\n" + "    <key>CFBundleTypeExtensions</key>\n" + "    <array>\n"
                + "        <string>jpeg</string>\n" + "        <string>png</string>\n"
                + "        <string>gif</string>\n" + "        <string>pic</string>\n" + "    </array>\n"
                + "</dict>";

        FileWriter fw;
        // create necessary directories
        File p = new File(filePath);
        p.mkdirs();

        //TODO: this is just a debug parameter
        boolean installed = new File(filePath + fileName).exists();
        if (!installed) {

            // Create info.plist
            fw = new FileWriter(filePath + fileName);
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(fileContent);
            bw.flush();
            bw.close();
            fw.close();
        }

        /*
         * STEP 2:   Create (executable) file which is called if the 
         *          application is run.
         */
        final String app_folder_path = filePath + "MacOS/";
        final String app_file_path = app_folder_path + name;
        new File(app_folder_path).mkdirs();
        String orig_jar_file = "";
        orig_jar_file = URLDecoder.decode(ClassLoader.getSystemClassLoader().getResource(".").getPath(),
                "UTF-8");

        // if Eclipse on-the-fly-compiling
        final String eclipseSubstring = "target/classes/";
        if (orig_jar_file.endsWith(eclipseSubstring)) {
            orig_jar_file = orig_jar_file.substring(0, orig_jar_file.length() - eclipseSubstring.length());

        }
        orig_jar_file += "paint.jar";

        final String jar_file_path = app_file_path + ".jar";
        final String content = "#!/bin/bash\n" + "echo $1\n" + "echo $2\n" + "echo $3\n" + "java -jar "
                + jar_file_path + " $@$0$1";

        // Create application file
        FileWriter fw2 = new FileWriter(app_file_path);
        BufferedWriter bw_2 = new BufferedWriter(fw2);
        bw_2.write(content);
        bw_2.flush();
        bw_2.close();
        fw2.close();

        // Make the file executable

        final String command0 = "chmod a+x " + app_file_path;
        String ret = Util.executeCommandLinux(command0);

        /*
         * Step 3:   Copy .jar file to the destination.
         */

        final String command1 = "cp " + orig_jar_file + " " + jar_file_path;
        String ret1 = Util.executeCommandLinux(command1);

        if (!installed) {

            final String command2 = "/System/Library/Frameworks/CoreServices.framework/Versions/"
                    + "A/Frameworks/LaunchServices.framework/Versions/A/Support/"
                    + "lsregister -f /Applications/" + app_name + "/";
            String ret2 = Util.executeCommandLinux(command2);

            final String command3 = "killall Finder";
            String ret3 = Util.executeCommandLinux(command3);

            String s = "Operation log:\n";
            System.out.println(s);
            System.out.println(ret + "\n" + ret1 + "\n" + ret2 + "\n" + ret3);

        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.iksgmbh.sql.pojomemodb.utils.FileUtil.java

/**
 * Uses reader and writer to perform copy
 * @param sourcefile//www.  j a v a  2s. co m
 * @param targetFile
 */
public static void copyTextFile(final File sourcefile, final File targetFile) {
    if (!sourcefile.exists()) {
        throw new RuntimeException("Sourcefile does not exist: " + sourcefile.getAbsolutePath());
    }
    if (!sourcefile.isFile()) {
        throw new RuntimeException("Sourcefile is no file: " + sourcefile.getAbsolutePath());
    }
    final String targetdir = targetFile.getParent();
    if (!targetFile.getParentFile().exists()) {
        throw new RuntimeException("TargetDirectory does not exist: " + targetdir);
    }

    BufferedReader in = null;
    BufferedWriter out = null;
    try {
        out = IOEncodingHelper.STANDARD.getBufferedWriter(targetFile);
        in = IOEncodingHelper.STANDARD.getBufferedReader(sourcefile);
        int c;

        while ((c = in.read()) != -1)
            out.write(c);
    } catch (Exception e) {
        throw new RuntimeException("Error copying " + sourcefile.getAbsolutePath() + " to " + targetdir, e);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                throw new RuntimeException("Error closing reader " + in, e);
            }
        }
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                throw new RuntimeException("Error writer reader " + out, e);
            }
        }
    }
}

From source file:de.rinderle.softvis3d.layout.dot.ExecuteCommand.java

private void writeStringToOutput(final String inputGraph, final Process process) throws IOException {
    final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
    out.write(inputGraph);//from   ww w  .ja v a 2 s. com
    out.close();
}

From source file:org.kevinferrare.solarSystemDataRetriever.jplhorizons.webfetcher.JplHorizonRawDataRetriever.java

/**
 * Save the given content in a file whose name is the given "name" parameter.<br />
 * The file will be saved in the folder that was set using setFolderName and will have the .jplrawdata extension.
 * // w w  w . j a v a  2s  .co m
 * @param name
 *            the file name
 * @param content
 *            the content of the file
 * @throws IOException
 */
protected void saveEntryToFolder(String name, String content) throws IOException {
    name = name.replace("*", "").replace("/", "");
    String path = folderName + "/" + name + "." + RAW_DATA_FILE_EXTENSION;
    FileWriter fstream = new FileWriter(path);
    BufferedWriter out = new BufferedWriter(fstream);
    out.write(content);
    out.close();
}

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  ww . j  ava  2  s  .  c  om*/
    }

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

From source file:edu.utah.bmi.ibiomes.lite.ExperimentIndex.java

/**
 * Add entry (experiment) to index/*from ww  w  . ja  va2 s .  c  o  m*/
 * @param experimentPath Path to experiment
 * @throws IOException 
 */
public void addEntry(String experimentPath) throws IOException {
    BufferedWriter bw = new BufferedWriter(new FileWriter(this.file, true));
    bw.append(new IndexEntry(experimentPath).toString() + "\n");
    bw.close();
}

From source file:com.sir_m2x.messenger.utils.CustomExceptionHandler.java

private void writeToFile(final String stacktrace, final String filename) {
    try {/*from   w w w.  j av a  2  s  .  com*/
        File f = new File(this.localPath + "/");
        if (!f.exists())
            f.mkdir();
        BufferedWriter bos = new BufferedWriter(new FileWriter(this.localPath + "/" + filename));
        bos.write(stacktrace);
        bos.flush();
        bos.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.evidon.areweprivateyet.Crawler.java

private void recordLog(String name) throws IOException {
    BufferedWriter out = new BufferedWriter(new FileWriter(path + "crawl-" + name + ".log"));
    out.write(out.toString());//  ww  w .j  a v a 2  s .com
    out.close();
}

From source file:com.uwsoft.editor.controlles.handlers.CustomExceptionHandler.java

private void writeToFile(String stacktrace, String filename) {
    try {/*from w  w  w  .  j  a  v a2s  .  co  m*/
        //String localPath = DataManager.getMyDocumentsLocation();
        String localPath = DataManager.getInstance().getRootPath();
        System.out.println(localPath + File.separator + filename);
        BufferedWriter bos = new BufferedWriter(new FileWriter(localPath + File.separator + filename));
        bos.write(stacktrace);
        bos.flush();
        bos.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}