Example usage for java.io BufferedWriter newLine

List of usage examples for java.io BufferedWriter newLine

Introduction

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

Prototype

public void newLine() throws IOException 

Source Link

Document

Writes a line separator.

Usage

From source file:playground.artemc.analysis.AnalysisControlerListener.java

private void writeTimeCostAnalysis(IterationEndsEvent event) {

    String timeCostFilePath = this.scenario.getConfig().controler().getOutputDirectory() + "/timeCost.csv";
    File timeCostFile = new File(timeCostFilePath);

    try {// w  w w.j  av a  2s.com
        BufferedWriter timeCostWriter = new BufferedWriter(new FileWriter(timeCostFile));

        String header = "It;";
        for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
            header = header + "TTC_morning_" + mode + ";";
            header = header + "SCD_morning_" + mode + ";";
        }

        for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
            header = header + "TTC_evening_" + mode + ";";
            header = header + "SCD_evening_" + mode + ";";
        }

        timeCostWriter.write(header);
        timeCostWriter.newLine();

        for (Integer it : this.scd_morning.keySet()) {
            String data = it + ";";

            for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
                data = data + ttc_morning.get(it).get(mode) + ";";
                data = data + scd_morning.get(it).get(mode) + ";";
            }

            for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
                data = data + ttc_evening.get(it).get(mode) + ";";
                data = data + scd_evening.get(it).get(mode) + ";";
            }

            timeCostWriter.write(data);
            timeCostWriter.newLine();
        }
        timeCostWriter.close();
        log.info("Tinme cost analysis Output written to " + timeCostFilePath);

        //Write Time Cost Summary File for the Last Iteration      
        if (event.getIteration() == event.getControler().getScenario().getConfig().controler()
                .getLastIteration()) {
            String timeCostSummaryFilePath = this.scenario.getConfig().controler().getOutputDirectory()
                    + "/timeCostSummary.it" + event.getIteration() + ".csv";
            File timeCostSummaryFile = new File(timeCostSummaryFilePath);

            BufferedWriter timeCostSummaryWriter = new BufferedWriter(new FileWriter(timeCostSummaryFile));
            timeCostSummaryWriter.write(
                    "Mode;TTC_Total;SDC_total;TTC_morning;TTC_evening;SDC_morning;SDC_evening;Total_Journeys");
            timeCostSummaryWriter.newLine();

            for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
                String data = mode + ";";

                double sumTTCMorning = 0.0;
                double sumTTCEvening = 0.0;
                double sumSDCMorning = 0.0;
                double sumSDCEvening = 0.0;
                double sumTTCTotal = 0.0;
                double sumSDCTotal = 0.0;
                int sumModeJourneys = 0;

                for (int i = 0; i < ttcMorningByMode.get(mode).size(); i++) {
                    sumTTCMorning += ttcMorningByMode.get(mode).get(i);
                }

                for (int i = 0; i < ttcEveningByMode.get(mode).size(); i++) {
                    sumTTCEvening += ttcEveningByMode.get(mode).get(i);
                }
                for (int i = 0; i < sdcMorningByMode.get(mode).size(); i++) {
                    sumSDCMorning += sdcMorningByMode.get(mode).get(i);
                }
                for (int i = 0; i < sdcEveningByMode.get(mode).size(); i++) {
                    sumSDCEvening += sdcEveningByMode.get(mode).get(i);
                }
                sumTTCTotal = sumTTCMorning + sumTTCEvening;
                sumSDCTotal = sumSDCMorning + sumSDCEvening;
                sumModeJourneys = ttcMorningByMode.get(mode).size() + ttcEveningByMode.get(mode).size();

                data += sumTTCTotal + ";" + sumSDCTotal + ";" + sumTTCMorning + ";" + sumTTCEvening + ";"
                        + sumSDCMorning + ";" + sumSDCEvening + ";" + sumModeJourneys + ";";

                timeCostSummaryWriter.write(data);
                timeCostSummaryWriter.newLine();
            }
            timeCostSummaryWriter.close();
            log.info("Time cost summary for the last iteration was written to " + timeCostSummaryFilePath);

        }

        //Write Person Time Cost File for the last Iteration
        if (event.getIteration() == event.getControler().getScenario().getConfig().controler()
                .getLastIteration()) {
            String timeCostPersonFilePath = this.scenario.getConfig().controler().getOutputDirectory()
                    + "/timeCostPerPerson.it" + event.getIteration() + ".csv";
            File timeCostPersonFile = new File(timeCostPersonFilePath);

            BufferedWriter timeCostPersonWriter = new BufferedWriter(new FileWriter(timeCostPersonFile));
            timeCostPersonWriter
                    .write("Id;TTC_Total;SDC_total;TTC_morning;TTC_evening;SDC_morning;SDC_evening;");
            timeCostPersonWriter.newLine();

            double sumTTCTotal = 0.0;
            double sumSDCTotal = 0.0;

            for (Id<Person> id : event.getControler().getScenario().getPopulation().getPersons().keySet()) {
                if (!this.scheduleDelayCostHandler.getStuckedAgents().contains(id)) {
                    sumTTCTotal = this.scheduleDelayCostHandler.getTTC_morning().get(id)
                            + this.scheduleDelayCostHandler.getTTC_evening().get(id);
                    sumSDCTotal = this.scheduleDelayCostHandler.getSDC_morning().get(id)
                            + this.scheduleDelayCostHandler.getSDC_evening().get(id);

                    String data = id + ";";
                    data += sumTTCTotal + ";";
                    data += sumSDCTotal + ";";

                    data += this.scheduleDelayCostHandler.getTTC_morning().get(id) + ";";
                    data += this.scheduleDelayCostHandler.getTTC_evening().get(id) + ";";
                    data += this.scheduleDelayCostHandler.getSDC_morning().get(id) + ";";
                    data += this.scheduleDelayCostHandler.getSDC_evening().get(id) + ";";

                    timeCostPersonWriter.write(data);
                    timeCostPersonWriter.newLine();
                }
            }
            timeCostPersonWriter.close();
            log.info("Time cost per person for the last iteration was written to " + timeCostPersonFilePath);
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:sandbox.sfwatergit.analysis.runtime.AnalysisControlerListener.java

private void writeTimeCostAnalysis(IterationEndsEvent event) {

    String timeCostFilePath = this.scenario.getConfig().controler().getOutputDirectory() + "/timeCost.csv";
    File timeCostFile = new File(timeCostFilePath);

    try {/*  www. j a  v a  2  s .c  o m*/
        BufferedWriter timeCostWriter = new BufferedWriter(new FileWriter(timeCostFile));

        String header = "It;";
        for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
            header = header + "TTC_morning_" + mode + ";";
            header = header + "SCD_morning_" + mode + ";";
        }

        for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
            header = header + "TTC_evening_" + mode + ";";
            header = header + "SCD_evening_" + mode + ";";
        }

        timeCostWriter.write(header);
        timeCostWriter.newLine();

        for (Integer it : this.scd_morning.keySet()) {
            String data = it + ";";

            for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
                data = data + ttc_morning.get(it).get(mode) + ";";
                data = data + scd_morning.get(it).get(mode) + ";";
            }

            for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
                data = data + ttc_evening.get(it).get(mode) + ";";
                data = data + scd_evening.get(it).get(mode) + ";";
            }

            timeCostWriter.write(data);
            timeCostWriter.newLine();
        }
        timeCostWriter.close();
        log.info("Tinme cost analysis Output written to " + timeCostFilePath);

        //Write Time Cost Summary File for the Last Iteration      
        if (event.getIteration() == event.getServices().getScenario().getConfig().controler()
                .getLastIteration()) {
            String timeCostSummaryFilePath = this.scenario.getConfig().controler().getOutputDirectory()
                    + "/timeCostSummary.it" + event.getIteration() + ".csv";
            File timeCostSummaryFile = new File(timeCostSummaryFilePath);

            BufferedWriter timeCostSummaryWriter = new BufferedWriter(new FileWriter(timeCostSummaryFile));
            timeCostSummaryWriter.write(
                    "Mode;TTC_Total;SDC_total;TTC_morning;TTC_evening;SDC_morning;SDC_evening;Total_Journeys");
            timeCostSummaryWriter.newLine();

            for (String mode : this.scheduleDelayCostHandler.getUsedModes()) {
                String data = mode + ";";

                double sumTTCMorning = 0.0;
                double sumTTCEvening = 0.0;
                double sumSDCMorning = 0.0;
                double sumSDCEvening = 0.0;
                double sumTTCTotal = 0.0;
                double sumSDCTotal = 0.0;
                int sumModeJourneys = 0;

                for (int i = 0; i < ttcMorningByMode.get(mode).size(); i++) {
                    sumTTCMorning += ttcMorningByMode.get(mode).get(i);
                }

                for (int i = 0; i < ttcEveningByMode.get(mode).size(); i++) {
                    sumTTCEvening += ttcEveningByMode.get(mode).get(i);
                }
                for (int i = 0; i < sdcMorningByMode.get(mode).size(); i++) {
                    sumSDCMorning += sdcMorningByMode.get(mode).get(i);
                }
                for (int i = 0; i < sdcEveningByMode.get(mode).size(); i++) {
                    sumSDCEvening += sdcEveningByMode.get(mode).get(i);
                }
                sumTTCTotal = sumTTCMorning + sumTTCEvening;
                sumSDCTotal = sumSDCMorning + sumSDCEvening;
                sumModeJourneys = ttcMorningByMode.get(mode).size() + ttcEveningByMode.get(mode).size();

                data += sumTTCTotal + ";" + sumSDCTotal + ";" + sumTTCMorning + ";" + sumTTCEvening + ";"
                        + sumSDCMorning + ";" + sumSDCEvening + ";" + sumModeJourneys + ";";

                timeCostSummaryWriter.write(data);
                timeCostSummaryWriter.newLine();
            }
            timeCostSummaryWriter.close();
            log.info("Time cost summary for the last iteration was written to " + timeCostSummaryFilePath);

        }

        //Write Person Time Cost File for the last Iteration
        if (event.getIteration() == event.getServices().getScenario().getConfig().controler()
                .getLastIteration()) {
            String timeCostPersonFilePath = this.scenario.getConfig().controler().getOutputDirectory()
                    + "/timeCostPerPerson.it" + event.getIteration() + ".csv";
            File timeCostPersonFile = new File(timeCostPersonFilePath);

            BufferedWriter timeCostPersonWriter = new BufferedWriter(new FileWriter(timeCostPersonFile));
            timeCostPersonWriter
                    .write("Id;TTC_Total;SDC_total;TTC_morning;TTC_evening;SDC_morning;SDC_evening;");
            timeCostPersonWriter.newLine();

            double sumTTCTotal = 0.0;
            double sumSDCTotal = 0.0;

            for (Id<Person> id : event.getServices().getScenario().getPopulation().getPersons().keySet()) {
                if (!this.scheduleDelayCostHandler.getStuckedAgents().contains(id)) {
                    sumTTCTotal = this.scheduleDelayCostHandler.getTTC_morning().get(id)
                            + this.scheduleDelayCostHandler.getTTC_evening().get(id);
                    sumSDCTotal = this.scheduleDelayCostHandler.getSDC_morning().get(id)
                            + this.scheduleDelayCostHandler.getSDC_evening().get(id);

                    String data = id + ";";
                    data += sumTTCTotal + ";";
                    data += sumSDCTotal + ";";

                    data += this.scheduleDelayCostHandler.getTTC_morning().get(id) + ";";
                    data += this.scheduleDelayCostHandler.getTTC_evening().get(id) + ";";
                    data += this.scheduleDelayCostHandler.getSDC_morning().get(id) + ";";
                    data += this.scheduleDelayCostHandler.getSDC_evening().get(id) + ";";

                    timeCostPersonWriter.write(data);
                    timeCostPersonWriter.newLine();
                }
            }
            timeCostPersonWriter.close();
            log.info("Time cost per person for the last iteration was written to " + timeCostPersonFilePath);
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.baomidou.mybatisplus.generator.AutoGenerator.java

/**
 * ?// www.  j  av a 2 s  .c o m
 *
 * @param columns
 * @param types
 * @param comments
 * @throws IOException
 */
protected void buildEntityBean(List<String> columns, List<String> types, List<String> comments,
        String tableComment, Map<String, IdInfo> idMap, String table, String beanName) throws IOException {
    File beanFile = new File(PATH_ENTITY, beanName + ".java");
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(beanFile)));
    bw.write("package " + config.getEntityPackage() + ";");
    bw.newLine();
    bw.newLine();
    bw.write("import java.io.Serializable;");
    bw.newLine();
    if (isDate(types)) {
        bw.write("import java.util.Date;");
        bw.newLine();
    }
    if (isDecimal(types)) {
        bw.write("import java.math.BigDecimal;");
        bw.newLine();
    }
    bw.newLine();
    if (config.getIdType() != IdType.ID_WORKER) {
        bw.write("import com.baomidou.mybatisplus.annotations.IdType;");
        bw.newLine();
    }
    bw.newLine();
    /*
     * ? BaseEntity 
     */
    if (null != config.getConfigBaseEntity() && null != config.getConfigBaseEntity().getPackageName()
            && !config.getEntityPackage().equals(config.getConfigBaseEntity().getPackageName())) {
        bw.write("import " + config.getConfigBaseEntity().getPackageName() + ";");
        bw.newLine();
    }
    bw.write("import com.baomidou.mybatisplus.annotations.TableField;");
    bw.newLine();
    if (null == config.getConfigBaseEntity()) {
        bw.write("import com.baomidou.mybatisplus.annotations.TableId;");
        bw.newLine();
    }
    if (table.contains("_")) {
        bw.write("import com.baomidou.mybatisplus.annotations.TableName;");
        bw.newLine();
    }
    bw = buildClassComment(bw, tableComment);
    bw.newLine();
    /* ? */
    if (table.contains("_")) {
        bw.write("@TableName(\"" + table + "\")");
        bw.newLine();
    }

    /**
     * ???? BaseEntity 
     */
    if (null != config.getConfigBaseEntity()) {
        bw.write("public class " + beanName + " extends " + config.getConfigBaseEntity().getClassName() + " {");
    } else {
        bw.write("public class " + beanName + " implements Serializable {");
    }
    bw.newLine();
    bw.newLine();
    bw.write("\t@TableField(exist = false)");
    bw.newLine();
    bw.write("\tprivate static final long serialVersionUID = 1L;");
    bw.newLine();
    int size = columns.size();
    for (int i = 0; i < size; i++) {
        bw.newLine();
        bw.write("\t/** " + comments.get(i) + " */");
        bw.newLine();
        /*
         * ID  <br> isLine ??
         */
        String column = columns.get(i);
        String field = processField(column);
        boolean isLine = column.contains("_");
        IdInfo idInfo = idMap.get(column);
        if (idInfo != null) {
            // @TableId(value = "test_id", type = IdType.AUTO)
            bw.write("\t@TableId");
            String idType = toIdType();
            if (isLine) {
                if (config.isDbColumnUnderline()) {
                    // 
                    if (null != idType) {
                        bw.write("(");
                        bw.write(idType);
                        bw.write(")");
                    }
                } else {
                    bw.write("(value = \"" + column + "\"");
                    if (null != idType) {
                        bw.write(", ");
                        bw.write(idType);
                    }
                    bw.write(")");
                }
            } else if (null != idType) {
                bw.write("(");
                bw.write(idType);
                bw.write(")");
            }
            bw.newLine();
        } else if (isLine && !config.isDbColumnUnderline()) {
            // @TableField(value = "test_type", exist = false)
            bw.write("\t@TableField(value = \"" + column + "\")");
            bw.newLine();
        }
        bw.write("\tprivate " + processType(types.get(i)) + " " + field + ";");
        bw.newLine();
    }

    /*
     * ??
     */
    this.buildEntityBeanColumnConstant(columns, types, comments, bw, size);
    bw.newLine();

    /*
     * ?get  set
     */
    for (int i = 0; i < size; i++) {
        String _tempType = processType(types.get(i));
        String _tempField = processField(columns.get(i));
        String _field = _tempField.substring(0, 1).toUpperCase() + _tempField.substring(1);
        bw.newLine();
        bw.write("\tpublic " + _tempType + " get" + _field + "() {");
        bw.newLine();
        bw.write("\t\treturn this." + _tempField + ";");
        bw.newLine();
        bw.write("\t}");
        bw.newLine();
        bw.newLine();

        /* ? */
        if (config.isBuliderModel()) {
            bw.write("\tpublic " + beanName + " set" + _field + "(" + _tempType + " " + _tempField + ") {");
            bw.newLine();
            bw.write("\t\tthis." + _tempField + " = " + _tempField + ";");
            bw.newLine();
            bw.write("\t\treturn this;");
        } else {
            bw.write("\tpublic void set" + _field + "(" + _tempType + " " + _tempField + ") {");
            bw.newLine();
            bw.write("\t\tthis." + _tempField + " = " + _tempField + ";");
        }
        bw.newLine();
        bw.write("\t}");
        bw.newLine();
    }

    bw.newLine();
    bw.write("}");
    bw.newLine();
    bw.flush();
    bw.close();
}

From source file:com.cyberway.issue.io.ArchiveReader.java

protected void cdxOutput(boolean toFile) throws IOException {
    BufferedWriter cdxWriter = null;
    if (toFile) {
        String cdxFilename = stripExtension(getReaderIdentifier(), DOT_COMPRESSED_FILE_EXTENSION);
        cdxFilename = stripExtension(cdxFilename, getDotFileExtension());
        cdxFilename += ('.' + CDX);
        cdxWriter = new BufferedWriter(new FileWriter(cdxFilename));
    }/*from   w  w  w  . j  a va  2  s. com*/

    String header = "CDX b e a m s c " + ((isCompressed()) ? "V" : "v") + " n g";
    if (toFile) {
        cdxWriter.write(header);
        cdxWriter.newLine();
    } else {
        System.out.println(header);
    }

    String strippedFileName = getStrippedFileName();
    try {
        for (Iterator<ArchiveRecord> ii = iterator(); ii.hasNext();) {
            ArchiveRecord r = ii.next();
            if (toFile) {
                cdxWriter.write(r.outputCdx(strippedFileName));
                cdxWriter.newLine();
            } else {
                System.out.println(r.outputCdx(strippedFileName));
            }
        }
    } finally {
        if (toFile) {
            cdxWriter.close();
        }
    }
}

From source file:org.apache.playframework.generator.mybatisplus.AutoGenerator.java

/**
 * ?/*from   w w  w .ja  va2 s. co m*/
 *
 * @param bw
 * @param idMap
 * @param columns
 * @throws IOException
 */
protected void buildSQL(BufferedWriter bw, Map<String, IdInfo> idMap, List<String> columns) throws IOException {
    int size = columns.size();
    bw.write("\t<!-- -->");
    bw.newLine();
    bw.write("\t<sql id=\"Base_Column_List\">");
    bw.newLine();
    bw.write("\t\t");

    /*
     * ?
     */
    DBType dbType = DBType.ORACLE;
    if (config.getConfigDataSource() == ConfigDataSource.MYSQL) {
        dbType = DBType.MYSQL;
    }

    /*
     * 
     */
    if (null != config.getConfigBaseEntity()) {
        for (String column : config.getConfigBaseEntity().getColumns()) {
            bw.write(SqlReservedWords.convert(dbType, column));
            if (column.contains("_")) {
                bw.write(" AS " + processField(column));
            }
            bw.write(", ");
        }
    }
    /**
     * 
     */
    for (int i = 0; i < size; i++) {
        String column = columns.get(i);
        IdInfo idInfo = idMap.get(column);
        if (idInfo != null) {
            bw.write(SqlReservedWords.convert(dbType, column));
            if (idInfo.getValue().contains("_")) {
                bw.write(" AS " + processField(idInfo.getValue()));
            }
        } else {
            if (null == config.getConfigBaseEntity()) {
                bw.write(" ");
            }
            bw.write(SqlReservedWords.convert(dbType, column));
            if (column.contains("_")) {
                bw.write(" AS " + processField(column));
            }
        }
        if (i != size - 1) {
            bw.write(",");
        }
    }
    bw.newLine();
    bw.write("\t</sql>");
    bw.newLine();
    bw.newLine();
}

From source file:fr.cs.examples.propagation.DSSTPropagation.java

/** Print the results in the output file
 *
 *  @param handler orbit handler//from  ww  w .  jav  a 2s  .  c  o  m
 *  @param output output file
 *  @param sart start date of propagation
 *  @throws OrekitException 
 *  @throws IOException 
 */
private void printOutput(final File output, final OrbitHandler handler, final AbsoluteDate start)
        throws OrekitException, IOException {
    // Output format:
    // time_from_start, a, e, i, raan, pa, aM, h, k, p, q, lM, px, py, pz, vx, vy, vz
    final String format = new String(
            " %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e %24.16e");
    final BufferedWriter buffer = new BufferedWriter(new FileWriter(output));
    buffer.write(
            "##   time_from_start(s)            a(km)                      e                      i(deg)         ");
    buffer.write(
            "         raan(deg)                pa(deg)              mean_anomaly(deg)              ey/h          ");
    buffer.write(
            "           ex/k                    hy/p                     hx/q             mean_longitude_arg(deg)");
    buffer.write(
            "       Xposition(km)           Yposition(km)             Zposition(km)           Xvelocity(km/s)    ");
    buffer.write("      Yvelocity(km/s)         Zvelocity(km/s)");
    buffer.newLine();
    for (Orbit o : handler.getOrbits()) {
        final Formatter f = new Formatter(new StringBuilder(), Locale.ENGLISH);
        // Time from start (s)
        final double time = o.getDate().durationFrom(start);
        // Semi-major axis (km)
        final double a = o.getA() / 1000.;
        // Keplerian elements
        // Eccentricity
        final double e = o.getE();
        // Inclination (degrees)
        final double i = Math.toDegrees(MathUtils.normalizeAngle(o.getI(), FastMath.PI));
        // Right Ascension of Ascending Node (degrees)
        KeplerianOrbit ko = new KeplerianOrbit(o);
        final double ra = Math
                .toDegrees(MathUtils.normalizeAngle(ko.getRightAscensionOfAscendingNode(), FastMath.PI));
        // Perigee Argument (degrees)
        final double pa = Math.toDegrees(MathUtils.normalizeAngle(ko.getPerigeeArgument(), FastMath.PI));
        // Mean Anomaly (degrees)
        final double am = Math
                .toDegrees(MathUtils.normalizeAngle(ko.getAnomaly(PositionAngle.MEAN), FastMath.PI));
        // Equinoctial elements
        // ey/h component of eccentricity vector
        final double h = o.getEquinoctialEy();
        // ex/k component of eccentricity vector
        final double k = o.getEquinoctialEx();
        // hy/p component of inclination vector
        final double p = o.getHy();
        // hx/q component of inclination vector
        final double q = o.getHx();
        // Mean Longitude Argument (degrees)
        final double lm = Math.toDegrees(MathUtils.normalizeAngle(o.getLM(), FastMath.PI));
        // Cartesian elements
        // Position along X in inertial frame (km)
        final double px = o.getPVCoordinates().getPosition().getX() / 1000.;
        // Position along Y in inertial frame (km)
        final double py = o.getPVCoordinates().getPosition().getY() / 1000.;
        // Position along Z in inertial frame (km)
        final double pz = o.getPVCoordinates().getPosition().getZ() / 1000.;
        // Velocity along X in inertial frame (km/s)
        final double vx = o.getPVCoordinates().getVelocity().getX() / 1000.;
        // Velocity along Y in inertial frame (km/s)
        final double vy = o.getPVCoordinates().getVelocity().getY() / 1000.;
        // Velocity along Z in inertial frame (km/s)
        final double vz = o.getPVCoordinates().getVelocity().getZ() / 1000.;
        buffer.write(
                f.format(format, time, a, e, i, ra, pa, am, h, k, p, q, lm, px, py, pz, vx, vy, vz).toString());
        buffer.newLine();
        f.close();
    }
    buffer.close();
}

From source file:com.baomidou.mybatisplus.generator.AutoGenerator.java

protected void buildEntityBeanColumnConstant(List<String> columns, List<String> types, List<String> comments,
        BufferedWriter bw, int size) throws IOException {
    /*//from w w w .  java 2 s .c o m
     * ???? false
     */
    if (config.isColumnConstant()) {
        for (int i = 0; i < size; i++) {
            String _tempType = processType(types.get(i));
            String _column = columns.get(i);
            bw.newLine();
            bw.write("\tpublic static final " + _tempType + " " + _column.toUpperCase() + " = \"" + _column
                    + "\";");
        }
        bw.newLine();
    }
}

From source file:org.apache.playframework.generator.mybatisplus.AutoGenerator.java

/**
 *  ResultMap ?/*from  w  w  w . jav  a2  s  .c  om*/
 *
 * @param bw
 * @param beanName
 * @param idMap
 * @param columns
 * @throws IOException
 */
protected void buildResultMap(BufferedWriter bw, String beanName, Map<String, IdInfo> idMap,
        List<String> columns) throws IOException {
    int size = columns.size();
    bw.write("\t<!-- -->");
    bw.newLine();
    bw.write("\t<resultMap id=\"BaseResultMap\" type=\"" + config.getEntityPackage() + "." + beanName + "\">");
    bw.newLine();

    /*
     * ?
     */
    DBType dbType = DBType.ORACLE;
    if (config.getConfigDataSource() == ConfigDataSource.MYSQL) {
        dbType = DBType.MYSQL;
    }

    /*
     * 
     */
    if (null != config.getConfigBaseEntity()) {
        for (String column : config.getConfigBaseEntity().getColumns()) {
            bw.write("\t\t<result column=\"" + SqlReservedWords.convert(dbType, column) + "\" property=\""
                    + processField(column) + "\" />");
            bw.newLine();
        }
    }
    /**
     * 
     */
    for (int i = 0; i < size; i++) {
        String column = columns.get(i);
        IdInfo idInfo = idMap.get(column);
        if (idInfo != null) {
            bw.write("\t\t<id column=\"" + SqlReservedWords.convert(dbType, column) + "\" property=\""
                    + processField(idInfo.getValue()) + "\" />");
        } else {
            if (null == config.getConfigBaseEntity()) {
                bw.write(" ");
            }
            bw.write("\t\t<result column=\"" + SqlReservedWords.convert(dbType, column) + "\" property=\""
                    + processField(column) + "\" />");
        }
        if (i != size - 1) {
            bw.newLine();
        }
    }
    bw.newLine();
    bw.write("\t</resultMap>");
    bw.newLine();
    bw.newLine();
}

From source file:com.imaginary.home.cloud.CloudTest.java

@Before
public void setUp() throws Exception {
    cloudAPI = System.getProperty("cloudAPI", "http://15.185.177.82:8080");
    File f = new File("target/iha");

    if (!f.exists()) {
        //noinspection ResultOfMethodCallIgnored
        f.mkdir();/*from ww  w . j  a  va2  s  .c o  m*/
    }
    f = new File(HomeController.CONFIG_FILE);
    if (!f.exists()) {
        HashMap<String, Object> cfg = new HashMap<String, Object>();

        cfg.put("name", "Relay Test");

        ArrayList<Map<String, Object>> systems = new ArrayList<Map<String, Object>>();
        HashMap<String, Object> hue = new HashMap<String, Object>();
        HashMap<String, Object> auth = new HashMap<String, Object>();

        String hueIp = System.getProperty("ip");
        String hueAccessKey = System.getProperty("accessKey");

        auth.put("ipAddress", hueIp);
        auth.put("accessKey", hueAccessKey);

        hue.put("cname", Hue.class.getName());
        hue.put("id", "1");
        hue.put("authenticationProperties", auth);
        hue.put("customProperties", new HashMap<String, Object>());
        systems.add(hue);
        cfg.put("systems", systems);

        cfg.put("services", new ArrayList<Map<String, Object>>());

        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));

        writer.write((new JSONObject(cfg)).toString());
        writer.newLine();
        writer.flush();
        writer.close();
    }
    if (name.getMethodName().equals("createLocation") && apiKeyId == null) {
        setupUser();
    }
    if (name.getMethodName().equals("initializePairing") && locationId == null) {
        setupLocation();
    }
    if (name.getMethodName().equals("pair") && pairingCode == null) {
        setupPairing();
    }
    if (name.getMethodName().equals("token") && relayKeyId == null) {
        setupRelay();
    }
    if (name.getMethodName().equals("pushState") && token == null) {
        setupToken();
    }
    if (name.getMethodName().equals("listDevices") && testDeviceId == null) {
        setupDevices();
    }
    if (name.getMethodName().equals("flipOn") && testDeviceId == null) {
        setupDevices();
    }
    if (name.getMethodName().equals("listCommands") && testCommandId == null) {
        setupCommand();
    }
    if (name.getMethodName().equals("fetchWaitingCommands") && testCommandId == null) {
        setupCommand();
    }
}

From source file:net.arccotangent.pacchat.net.KeyUpdateClient.java

public void run() {
    Socket socket;/*from w ww .  j a  va2s  .  c  o m*/
    BufferedReader input;
    BufferedWriter output;

    kuc_log.i("Connecting to server at " + server_ip);

    try {
        socket = new Socket();
        socket.connect(new InetSocketAddress(InetAddress.getByName(server_ip), Server.PORT), 1000);
        input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        output = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
    } catch (SocketTimeoutException e) {
        kuc_log.e("Connection to server timed out!");
        e.printStackTrace();
        return;
    } catch (ConnectException e) {
        kuc_log.e("Connection to server was refused!");
        e.printStackTrace();
        return;
    } catch (UnknownHostException e) {
        kuc_log.e("You entered an invalid IP address!");
        e.printStackTrace();
        return;
    } catch (IOException e) {
        kuc_log.e("Error connecting to server!");
        e.printStackTrace();
        return;
    }

    try {
        kuc_log.i("Requesting a key update.");
        output.write("302 request key update");
        output.newLine();
        output.flush();

        kuc_log.i("Awaiting response from server.");
        String update = input.readLine();
        switch (update) {
        case "303 update":
            kuc_log.i("Server accepted update request, sending public key.");
            String pubkeyB64 = Base64.encodeBase64String(Main.getKeypair().getPublic().getEncoded());
            output.write(pubkeyB64);
            output.newLine();
            output.flush();
            output.close();
            break;
        case "304 no update":
            kuc_log.i("Server rejected update request, closing connection.");
            input.close();
            output.close();
            break;
        case "305 update unavailable":
            kuc_log.i("Server cannot update at this time, try again later.");
            input.close();
            output.close();
            break;
        default:
            kuc_log.i("Server sent back invalid response");
            input.close();
            output.close();
            break;
        }
    } catch (IOException e) {
        kuc_log.e("Error in key update request!");
        e.printStackTrace();
    }
}