List of usage examples for java.lang Float parseFloat
public static float parseFloat(String s) throws NumberFormatException
From source file:hivemall.classifier.KernelExpansionPassiveAggressiveUDTF.java
@Override protected CommandLine processOptions(ObjectInspector[] argOIs) throws UDFArgumentException { float pkc = 1.f; float c = 1.f; String algo = "pa1"; final CommandLine cl = super.processOptions(argOIs); if (cl != null) { String pkc_str = cl.getOptionValue("pkc"); if (pkc_str != null) { pkc = Float.parseFloat(pkc_str); }// w w w . j a v a2 s .c o m String c_str = cl.getOptionValue("c"); if (c_str != null) { c = Float.parseFloat(c_str); if (c <= 0.f) { throw new UDFArgumentException("Aggressiveness parameter C must be C > 0: " + c); } } algo = cl.getOptionValue("algo", algo); } if ("pa1".equalsIgnoreCase(algo)) { this._algo = new PA1(c); } else if ("pa2".equalsIgnoreCase(algo)) { this._algo = new PA2(c); } else if ("pa".equalsIgnoreCase(algo)) { this._algo = new PA(); } else { throw new UDFArgumentException("Unsupported algorithm: " + algo); } this._pkc = pkc; return cl; }
From source file:com.inktomi.wxmetar.MetarParser.java
static boolean parseWinds(String token, final Metar metar) { boolean rval = Boolean.FALSE; // Winds will be the only element that ends in knots if (StringUtils.endsWith(token, "KT")) { // At this point, we know we should handle this token rval = Boolean.TRUE;/*from w ww .j av a 2 s . c o m*/ // Remove the KT token = StringUtils.remove(token, "KT"); // Is it variable? if (StringUtils.startsWith(token, "VRB")) { metar.winds.variable = Boolean.TRUE; // Trim of the VRB token = StringUtils.remove(token, "VRB"); metar.winds.windSpeed = Float.parseFloat(token); // Stop processing this token return rval; } // At this point, we know the first 3 chars are wind direction metar.winds.windDirection = Integer.parseInt(StringUtils.substring(token, 0, 3)); // Is it gusting? 17012G24 int postionOfG = StringUtils.indexOf(token, "G"); if (postionOfG > -1) { metar.winds.windGusts = Float .parseFloat(StringUtils.substring(token, postionOfG + 1, token.length())); metar.winds.windSpeed = Float.parseFloat(StringUtils.substring(token, 3, postionOfG)); } // Is it just a normal wind measurement? // 26006 if (postionOfG == -1 && !metar.winds.variable) { metar.winds.windSpeed = Float.parseFloat(StringUtils.substring(token, 2, token.length())); } } return rval; }
From source file:Data.Player.java
public void behindthenet(String input) { temp = input.split("\">"); //System.out.println(name + " -- " + temp[9].substring(0, temp[9].indexOf("<")-1)); if (temp[9].substring(0, temp[9].indexOf("<") - 1).contains("-") || temp[9].substring(0, temp[9].indexOf("<") - 1).isEmpty()) { onice_sht_pcnt = 0;//from w w w. j av a2 s . com } else { onice_sht_pcnt = Float.parseFloat(temp[9].substring(0, temp[9].indexOf("<") - 1)); } // if (Integer.parseInt(year) == 2015 && age < 28 && gp > 20 && points60 > 2.0 && onice_sht_pcnt < 7.5){ // printPlayer(); // } }
From source file:edu.snu.leader.hidden.personality.StandardUpdateRulePersonalityCalculator.java
/** * Initializes the updater//from ww w . java 2s . c o m * * @param simState The simulation's state * @see edu.snu.leader.hidden.personality.PersonalityCalculator#initialize(edu.snu.leader.hidden.SimulationState) */ @Override public void initialize(SimulationState simState) { _LOG.trace("Entering initialize( simState )"); // Get the properties Properties props = simState.getProps(); // Get the discount value String discountStr = props.getProperty(_DISCOUNT_KEY); Validate.notEmpty(discountStr, "Personality discount (key=" + _DISCOUNT_KEY + ") may not be empty"); _discount = Float.parseFloat(discountStr); _LOG.info("Using _discount=[" + _discount + "]"); // Get the true winner discount value String trueWinnerDiscountStr = props.getProperty(_TRUE_WINNER_DISCOUNT_KEY); if (null != trueWinnerDiscountStr) { _trueWinnerDiscount = Float.parseFloat(trueWinnerDiscountStr); } else { _trueWinnerDiscount = _discount; } _LOG.info("Using _trueWinnerDiscount=[" + _trueWinnerDiscount + "]"); // Get the true loser discount value String trueLoserDiscountStr = props.getProperty(_TRUE_LOSER_DISCOUNT_KEY); if (null != trueLoserDiscountStr) { _trueLoserDiscount = Float.parseFloat(trueLoserDiscountStr); } else { _trueLoserDiscount = _discount; } _LOG.info("Using _trueLoserDiscount=[" + _trueLoserDiscount + "]"); // Get the winner reward String winnerRewardStr = props.getProperty(_WINNER_REWARD_KEY); Validate.notEmpty(winnerRewardStr, "Winner reward (key=[" + _WINNER_REWARD_KEY + "]) may not be empty"); _winnerReward = Float.parseFloat(winnerRewardStr); _LOG.info("Using _winnerReward=[" + _winnerReward + "]"); // Get the loser penalty String loserPenaltyStr = props.getProperty(_LOSER_PENALTY_KEY); Validate.notEmpty(loserPenaltyStr, "Loser penalty (key=[" + _LOSER_PENALTY_KEY + "]) may not be empty"); _loserPenalty = Float.parseFloat(loserPenaltyStr); _LOG.info("Using _loserPenalty=[" + _loserPenalty + "]"); // Get the true winner effect flag String trueWinnerEffectStr = props.getProperty(_TRUE_WINNER_EFFECTS_ACTIVE_KEY); Validate.notEmpty(trueWinnerEffectStr, "True winner effects active flag (key=[" + _TRUE_WINNER_EFFECTS_ACTIVE_KEY + "]) may not be empty"); _trueWinnerEffectActive = Boolean.parseBoolean(trueWinnerEffectStr); _LOG.info("Using _trueWinnerEffectActive=[" + _trueWinnerEffectActive + "]"); // Get the true loser effect flag String trueLoserEffectStr = props.getProperty(_TRUE_LOSER_EFFECTS_ACTIVE_KEY); Validate.notEmpty(trueLoserEffectStr, "True loser effects active flag (key=[" + _TRUE_LOSER_EFFECTS_ACTIVE_KEY + "]) may not be empty"); _trueLoserEffectActive = Boolean.parseBoolean(trueLoserEffectStr); _LOG.info("Using _trueLoserEffectActive=[" + _trueLoserEffectActive + "]"); // Get the min personality String minPersonalityStr = props.getProperty(_MIN_PERSONALITY_KEY); Validate.notEmpty(minPersonalityStr, "Minimum personality value (key=" + _MIN_PERSONALITY_KEY + ") may not be empty"); _minPersonality = Float.parseFloat(minPersonalityStr); _LOG.info("Using _minPersonality=[" + _minPersonality + "]"); // Get the max personality String maxPersonalityStr = props.getProperty(_MAX_PERSONALITY_KEY); Validate.notEmpty(maxPersonalityStr, "Maximum personality value (key=" + _MAX_PERSONALITY_KEY + ") may not be empty"); _maxPersonality = Float.parseFloat(maxPersonalityStr); _LOG.info("Using _maxPersonality=[" + _maxPersonality + "]"); _LOG.trace("Leaving initialize( simState )"); }
From source file:br.bireme.mlts.MoreLikeThatServlet.java
@Override public void init(final ServletConfig servletConfig) throws ServletException { final String sdir = servletConfig.getInitParameter("INDEX_DIR"); if (sdir == null) { throw new ServletException("missing index directory (INDEX_DIR) " + "parameter."); }/*from www.j a v a 2s .c om*/ final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_36); try { mlt = new MoreLikeThat(new File(sdir), analyzer); } catch (IOException ex) { throw new ServletException(ex); } final String maxHits = servletConfig.getInitParameter("MAX_HITS"); if (maxHits != null) { mlt.setMaxHits(Integer.parseInt(maxHits)); } final String minTermFreq = servletConfig.getInitParameter("MIN_TERM_FREQ"); if (minTermFreq != null) { mlt.setMinTermFreq(Integer.parseInt(minTermFreq)); } final String minDocFreq = servletConfig.getInitParameter("MIN_DOC_FREQ"); if (minDocFreq != null) { mlt.setMinDocFreq(Integer.parseInt(minDocFreq)); } final String maxDocFreq = servletConfig.getInitParameter("MAX_DOC_FREQ"); if (maxDocFreq != null) { mlt.setMaxDocFreq(Integer.parseInt(maxDocFreq)); } final String minWordLen = servletConfig.getInitParameter("MIN_WORD_LENGTH"); if (minWordLen != null) { mlt.setMinWordLen(Integer.parseInt(minWordLen)); } final String maxWordLen = servletConfig.getInitParameter("MAX_WORD_LENGTH"); if (maxWordLen != null) { mlt.setMaxWordLen(Integer.parseInt(maxWordLen)); } final String maxQueryTerms = servletConfig.getInitParameter("MAX_QUERY_TERMS"); if (maxQueryTerms != null) { mlt.setMaxQueryTerms(Integer.parseInt(maxQueryTerms)); } final String maxNumTokensParsed = servletConfig.getInitParameter("MAX_NUM_TOKENS_PARSED"); if (maxNumTokensParsed != null) { mlt.setMaxNumTokensParsed(Integer.parseInt(maxNumTokensParsed)); } final String minScore = servletConfig.getInitParameter("MIN_SCORE"); if (minScore != null) { mlt.setMinScore(Float.parseFloat(minScore)); } }
From source file:org.f3.tools.framework.Reporter.java
private Float percentChange0(boolean performance, Map<String, ResultData> in1, Map<String, ResultData> in2, String key) {// w w w . j ava2 s . com float f1 = 0; float f2 = 0; ResultData rd = null; if (in1 != null) { rd = in1.get(key); f1 = (float) ((rd == null) ? 0.0 : Float.parseFloat((performance ? rd.getPerformance() : rd.getHeapsize()))); } if (in2 != null) { rd = in2.get(key); f2 = (float) ((rd == null) ? 0.0 : Float.parseFloat((performance ? rd.getPerformance() : rd.getHeapsize()))); } float change = (f1 - f2) / f1 * 100; return Float.parseFloat(String.format("%10.2f", change)); }
From source file:com.sqewd.open.dal.core.persistence.handlers.StringArrayConvertor.java
private Object getArrayData(String[] data, Field field) throws Exception { Class<?> type = field.getType().getComponentType(); if (type.equals(String.class)) { return data; } else if (EnumPrimitives.isPrimitiveType(type)) { EnumPrimitives et = EnumPrimitives.type(type); if (type.isPrimitive()) { switch (et) { case ECharacter: char[] carr = new char[data.length]; for (int ii = 0; ii < carr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) carr[ii] = data[ii].charAt(0); }/*w w w . j a v a 2 s. co m*/ return carr; case EShort: short[] sarr = new short[data.length]; for (int ii = 0; ii < sarr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) sarr[ii] = Short.parseShort(data[ii]); } return sarr; case EInteger: int[] iarr = new int[data.length]; for (int ii = 0; ii < iarr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) iarr[ii] = Integer.parseInt(data[ii]); } return iarr; case ELong: long[] larr = new long[data.length]; for (int ii = 0; ii < larr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) larr[ii] = Long.parseLong(data[ii]); } return larr; case EFloat: float[] farr = new float[data.length]; for (int ii = 0; ii < farr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) farr[ii] = Float.parseFloat(data[ii]); } return farr; case EDouble: double[] darr = new double[data.length]; for (int ii = 0; ii < darr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) darr[ii] = Double.parseDouble(data[ii]); } return darr; } } else { switch (et) { case ECharacter: Character[] carr = new Character[data.length]; for (int ii = 0; ii < carr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) carr[ii] = data[ii].charAt(0); } return carr; case EShort: Short[] sarr = new Short[data.length]; for (int ii = 0; ii < sarr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) sarr[ii] = Short.parseShort(data[ii]); } return sarr; case EInteger: Integer[] iarr = new Integer[data.length]; for (int ii = 0; ii < iarr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) iarr[ii] = Integer.parseInt(data[ii]); } return iarr; case ELong: Long[] larr = new Long[data.length]; for (int ii = 0; ii < larr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) larr[ii] = Long.parseLong(data[ii]); } return larr; case EFloat: Float[] farr = new Float[data.length]; for (int ii = 0; ii < farr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) farr[ii] = Float.parseFloat(data[ii]); } return farr; case EDouble: Double[] darr = new Double[data.length]; for (int ii = 0; ii < darr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) darr[ii] = Double.parseDouble(data[ii]); } return darr; } } } else if (type.equals(Date.class)) { Date[] dtarr = new Date[data.length]; for (int ii = 0; ii < dtarr.length; ii++) { if (data[ii] != null && !data[ii].isEmpty()) { dtarr[ii] = DateUtils.fromString(data[ii]); } } } throw new Exception("Unsupported Array element type [" + type.getCanonicalName() + "]"); }
From source file:com.uws.campus_app.core.maps.BaseCustomMap.java
private MarkerInfo getMarkerInfoFromJson(JSONObject marker) { MarkerInfo markerInfo = new MarkerInfo(); try {/*from w w w .j a va2s. com*/ markerInfo.lat = Float.parseFloat(marker.getString("lat")); markerInfo.lng = Float.parseFloat(marker.getString("lng")); markerInfo.title = marker.getString("title"); markerInfo.id = marker.getString("id"); markerInfo.childMarkers = new ArrayList<>(); JSONArray childMarkers = marker.getJSONArray("childMarkers"); for (int x = 0; x < childMarkers.length(); x++) { markerInfo.childMarkers.add(getMarkerInfoFromJson(childMarkers.getJSONObject(x))); } } catch (Exception e) { Log.e("getMarkerInfoFromJson", e.getMessage()); } return markerInfo; }
From source file:com.lge.friendsCamera.CustomListAdapter.java
/** * Convert size unit from Bytes to MB/*from w w w. j ava 2s . co m*/ * * @param sizeString size in Bytes * @return size in MB */ private String convertBytesToMB(String sizeString) { double size = Float.parseFloat(sizeString); double mbSize = size / (1024 * 1024); return String.format("%.2f", mbSize) + "MB"; }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step8GoldDataAggregator.java
public static void main(String[] args) throws Exception { String inputDir = args[0] + "/"; // output dir File outputDir = new File(args[1]); File turkersConfidence = new File(args[2]); if (outputDir.exists()) { outputDir.delete();/*www . j av a 2s . c o m*/ } outputDir.mkdir(); List<String> annotatorsIDs = new ArrayList<>(); // for (File f : FileUtils.listFiles(new File(inputDir), new String[] { "xml" }, false)) { // QueryResultContainer queryResultContainer = QueryResultContainer // .fromXML(FileUtils.readFileToString(f, "utf-8")); // for (QueryResultContainer.SingleRankedResult rankedResults : queryResultContainer.rankedResults) { // for (QueryResultContainer.MTurkRelevanceVote relevanceVote : rankedResults.mTurkRelevanceVotes) { // if (!annotatorsIDs.contains(relevanceVote.turkID)) // annotatorsIDs.add(relevanceVote.turkID); // } // } // } HashMap<String, Integer> countVotesForATurker = new HashMap<>(); // creates temporary file with format for mace // Hashmap annotations: key is the id of a document and a sentence // Value is an array votes[] of turkers decisions: true or false (relevant or not) // the length of this array equals the number of annotators in List<String> annotatorsIDs. // If an annotator worked on the task his decision is written in the array otherwise the value is NULL // key: queryID + clueWebID + sentenceID // value: true and false annotations TreeMap<String, Annotations> annotations = new TreeMap<>(); for (File f : FileUtils.listFiles(new File(inputDir), new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); System.out.println("Reading " + f.getName()); for (QueryResultContainer.SingleRankedResult rankedResults : queryResultContainer.rankedResults) { String documentID = rankedResults.clueWebID; for (QueryResultContainer.MTurkRelevanceVote relevanceVote : rankedResults.mTurkRelevanceVotes) { Integer turkerID; if (!annotatorsIDs.contains(relevanceVote.turkID)) { annotatorsIDs.add(relevanceVote.turkID); turkerID = annotatorsIDs.size() - 1; } else { turkerID = annotatorsIDs.indexOf(relevanceVote.turkID); } Integer count = countVotesForATurker.get(relevanceVote.turkID); if (count == null) { count = 0; } count++; countVotesForATurker.put(relevanceVote.turkID, count); String id; List<Integer> trueVotes; List<Integer> falseVotes; for (QueryResultContainer.SingleSentenceRelevanceVote singleSentenceRelevanceVote : relevanceVote.singleSentenceRelevanceVotes) if (!"".equals(singleSentenceRelevanceVote.sentenceID)) { id = f.getName() + "_" + documentID + "_" + singleSentenceRelevanceVote.sentenceID; Annotations turkerVotes = annotations.get(id); if (turkerVotes == null) { trueVotes = new ArrayList<>(); falseVotes = new ArrayList<>(); turkerVotes = new Annotations(trueVotes, falseVotes); } trueVotes = turkerVotes.trueAnnotations; falseVotes = turkerVotes.falseAnnotations; if ("true".equals(singleSentenceRelevanceVote.relevant)) { // votes[turkerID] = true; trueVotes.add(turkerID); } else if ("false".equals(singleSentenceRelevanceVote.relevant)) { // votes[turkerID] = false; falseVotes.add(turkerID); } else { throw new IllegalStateException("Annotation value of sentence " + singleSentenceRelevanceVote.sentenceID + " in " + rankedResults.clueWebID + " equals " + singleSentenceRelevanceVote.relevant); } try { int allVotesCount = trueVotes.size() + falseVotes.size(); if (allVotesCount > 5) { System.err.println(id + " doesn't have 5 annotators: true: " + trueVotes.size() + " false: " + falseVotes.size()); // nasty hack, we're gonna strip some data; true votes first /* we can't do that, it breaks something down the line int toRemove = allVotesCount - 5; if (trueVotes.size() >= toRemove) { trueVotes = trueVotes .subList(0, trueVotes.size() - toRemove); } else if ( falseVotes.size() >= toRemove) { falseVotes = falseVotes .subList(0, trueVotes.size() - toRemove); } */ System.err.println("Adjusted: " + id + " doesn't have 5 annotators: true: " + trueVotes.size() + " false: " + falseVotes.size()); } } catch (IllegalStateException e) { e.printStackTrace(); } turkerVotes.trueAnnotations = trueVotes; turkerVotes.falseAnnotations = falseVotes; annotations.put(id, turkerVotes); } else { throw new IllegalStateException( "Empty Sentence ID in " + f.getName() + " for turker " + turkerID); } } } } File tmp = printHashMap(annotations, annotatorsIDs.size()); String file = TEMP_DIR + "/" + tmp.getName(); MACE.main(new String[] { "--prefix", file }); //gets the keys of the documents and sentences ArrayList<String> lines = (ArrayList<String>) FileUtils.readLines(new File(file + ".prediction")); int i = 0; TreeMap<String, TreeMap<String, ArrayList<HashMap<String, String>>>> ids = new TreeMap<>(); ArrayList<HashMap<String, String>> sentences; if (lines.size() != annotations.size()) { throw new IllegalStateException( "The size of prediction file is " + lines.size() + "but expected " + annotations.size()); } for (Map.Entry entry : annotations.entrySet()) { //1001.xml_clueweb12-1905wb-13-07360_8783 String key = (String) entry.getKey(); String[] IDs = key.split("_"); if (IDs.length > 2) { String queryID = IDs[0]; String clueWebID = IDs[1]; String sentenceID = IDs[2]; TreeMap<String, ArrayList<HashMap<String, String>>> clueWebIDs = ids.get(queryID); if (clueWebIDs == null) { clueWebIDs = new TreeMap<>(); } sentences = clueWebIDs.get(clueWebID); if (sentences == null) { sentences = new ArrayList<>(); } HashMap<String, String> sentence = new HashMap<>(); sentence.put(sentenceID, lines.get(i)); sentences.add(sentence); clueWebIDs.put(clueWebID, sentences); ids.put(queryID, clueWebIDs); } else { throw new IllegalStateException("Wrong ID " + key); } i++; } for (Map.Entry entry : ids.entrySet()) { TreeMap<Integer, String> value = (TreeMap<Integer, String>) entry.getValue(); String queryID = (String) entry.getKey(); QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(new File(inputDir, queryID), "utf-8")); for (QueryResultContainer.SingleRankedResult rankedResults : queryResultContainer.rankedResults) { for (Map.Entry val : value.entrySet()) { String clueWebID = (String) val.getKey(); if (clueWebID.equals(rankedResults.clueWebID)) { List<QueryResultContainer.SingleSentenceRelevanceVote> goldEstimatedLabels = new ArrayList<>(); List<QueryResultContainer.SingleSentenceRelevanceVote> turkersVotes = new ArrayList<>(); int size = 0; int hitSize = 0; String hitID = ""; for (QueryResultContainer.MTurkRelevanceVote vote : rankedResults.mTurkRelevanceVotes) { if (!hitID.equals(vote.hitID)) { hitID = vote.hitID; hitSize = vote.singleSentenceRelevanceVotes.size(); size = size + hitSize; turkersVotes.addAll(vote.singleSentenceRelevanceVotes); } else { if (vote.singleSentenceRelevanceVotes.size() != hitSize) { hitSize = vote.singleSentenceRelevanceVotes.size(); size = size + hitSize; turkersVotes.addAll(vote.singleSentenceRelevanceVotes); } } } ArrayList<HashMap<String, String>> sentenceList = (ArrayList<HashMap<String, String>>) val .getValue(); if (sentenceList.size() != turkersVotes.size()) { try { throw new IllegalStateException("Expected size of annotations is " + turkersVotes.size() + "but found " + sentenceList.size() + " for document " + rankedResults.clueWebID + " in " + queryID); } catch (IllegalStateException ex) { ex.printStackTrace(); } } for (QueryResultContainer.SingleSentenceRelevanceVote s : turkersVotes) { String valSentence = null; for (HashMap<String, String> anno : sentenceList) { if (anno.keySet().contains(s.sentenceID)) { valSentence = anno.get(s.sentenceID); } } QueryResultContainer.SingleSentenceRelevanceVote singleSentenceVote = new QueryResultContainer.SingleSentenceRelevanceVote(); singleSentenceVote.sentenceID = s.sentenceID; if (("false").equals(valSentence)) { singleSentenceVote.relevant = "false"; } else if (("true").equals(valSentence)) { singleSentenceVote.relevant = "true"; } else { throw new IllegalStateException("Annotation value of sentence " + singleSentenceVote.sentenceID + " equals " + val.getValue()); } goldEstimatedLabels.add(singleSentenceVote); } rankedResults.goldEstimatedLabels = goldEstimatedLabels; } } } File outputFile = new File(outputDir, queryID); FileUtils.writeStringToFile(outputFile, queryResultContainer.toXML(), "utf-8"); System.out.println("Finished " + outputFile); } ArrayList<String> annotators = (ArrayList<String>) FileUtils.readLines(new File(file + ".competence")); FileWriter fileWriter; StringBuilder sb = new StringBuilder(); for (int j = 0; j < annotatorsIDs.size(); j++) { String[] s = annotators.get(0).split("\t"); Float score = Float.parseFloat(s[j]); String turkerID = annotatorsIDs.get(j); System.out.println(turkerID + " " + score + " " + countVotesForATurker.get(turkerID)); sb.append(turkerID).append(" ").append(score).append(" ").append(countVotesForATurker.get(turkerID)) .append("\n"); } fileWriter = new FileWriter(turkersConfidence); fileWriter.append(sb.toString()); fileWriter.close(); }