List of usage examples for java.lang String toString
public String toString()
From source file:eu.stratosphere.pact.test.pactPrograms.TPCHQuery3ITCase.java
private String[] splitInputString(String inputString, char splitChar, int noSplits) { String splitString = inputString.toString(); String[] splits = new String[noSplits]; int partitionSize = (splitString.length() / noSplits) - 2; // split data file and copy parts for (int i = 0; i < noSplits - 1; i++) { int cutPos = splitString.indexOf(splitChar, (partitionSize < splitString.length() ? partitionSize : (splitString.length() - 1))); splits[i] = splitString.substring(0, cutPos) + "\n"; splitString = splitString.substring(cutPos + 1); }/*from ww w . j a va2 s . c om*/ splits[noSplits - 1] = splitString; return splits; }
From source file:com.noelportugal.amazonecho.AmazonEchoApi.java
public String getLatestHistory() throws IOException { String output = httpGet("/api/activities?startTime=&size=1&offset=-1"); //System.out.println(output); fLogger.log(Level.INFO, output); // Parse JSON Object obj = JSONValue.parse(output); JSONObject jsonObject = (JSONObject) obj; JSONArray values = (JSONArray) jsonObject.get("activities"); JSONObject item = (JSONObject) values.get(0); String text = item.get("description").toString(); fLogger.log(Level.INFO, text.toString()); //Get the summary text Object obj2 = JSONValue.parse(text); JSONObject jsonObject2 = (JSONObject) obj2; text = jsonObject2.get("summary").toString(); if (!checkItemId(text)) { return text; } else {/*w w w .j a va 2s. c o m*/ return null; } }
From source file:ch.epfl.lsir.xin.algorithm.baseline.GlobalAverage.java
@Override public void readModel(String file) { // TODO Auto-generated method stub logger.append("Read an existing model from a local file: " + file.toString() + "\n"); try {/* w w w.j a va 2s.co m*/ BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { this.mean = Double.parseDouble(line.trim()); } reader.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:eu.stratosphere.fuzzyjoin.test.TestA.java
private String[] splitInputString(String inputString, char splitChar, int noSplits) { String splitString = inputString.toString(); String[] splits = new String[noSplits]; int partitionSize = (splitString.length() / noSplits) - 2; // split data file and copy parts for (int i = 0; i < noSplits - 1; i++) { int cutPos = splitString.indexOf(splitChar, (partitionSize < splitString.length() ? partitionSize : (splitString.length() - 1))); splits[i] = splitString.substring(0, cutPos) + "\n"; splitString = splitString.substring(cutPos + 1); }// w w w. j a v a 2s . c o m splits[noSplits - 1] = splitString; return splits; }
From source file:com.intel.hadoop.graphbuilder.preprocess.mapreduce.CreateGraphMR.java
/** * Set the user defined options.//from w w w.j av a 2 s . com * * @param userOpts * a Map of option key value pairs. */ public void setUserOptions(HashMap<String, String> userOpts) { Set<String> s = userOpts.keySet(); for (String key : s) conf.set(key, userOpts.get(key.toString())); }
From source file:com.tek271.reverseProxy.servlet.ProxyFilter.java
private static MultipartEntity getMultipartEntity(HttpServletRequest request) { MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); Enumeration<String> en = request.getParameterNames(); while (en.hasMoreElements()) { String name = en.nextElement(); String value = request.getParameter(name); try {// w ww.jav a 2s . co m if (name.equals("file")) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(10000000);// 10 Mo List items = upload.parseRequest(request); Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); File file = new File(item.getName()); FileOutputStream fos = new FileOutputStream(file); fos.write(item.get()); fos.flush(); fos.close(); entity.addPart(name, new FileBody(file, "application/zip")); } } else { entity.addPart(name, new StringBody(value.toString(), "text/plain", Charset.forName("UTF-8"))); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (FileUploadException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (FileNotFoundException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } return entity; }
From source file:nz.net.orcon.kanban.controllers.FormController.java
@RequestMapping(value = "", method = RequestMethod.POST) public @ResponseBody Form createForm(@RequestBody Form form) throws Exception { if (form.getPath() != null) { logger.warn("Attempt to update form using POST"); throw new Exception("Attempt to Update Form using POST. Use PUT instead"); }/*from ww w.ja v a 2 s.c o m*/ ObjectContentManager ocm = ocmFactory.getOcm(); try { String newId = IdentifierTools.getIdFromNamedModelClass(form); form.setPath(String.format(URI.FORM_URI, newId.toString())); // Ensure that the current user is assigned as the owner of the new form. // By default also add the administrators group as a owner. form.setRoles(this.securityTool.initRole(form.getRoles())); ocm.insert(form); ocm.save(); this.cacheInvalidationManager.invalidate(FORM, newId); } finally { ocm.logout(); } return form; }
From source file:gov.nih.nci.caadapter.sdtm.SDTM_CSVReader.java
public MultiMap readCSVFile(String filename) throws Exception { BufferedReader inputTMP = new BufferedReader(new FileReader(filename)); String lineTMP = null; EmptyStringTokenizer strTk = null;//from w w w . j av a 2 s .c om while ((lineTMP = inputTMP.readLine()) != null) { String columnName = ""; ArrayList<String> dataForEachColumn = new ArrayList<String>(); strTk = new EmptyStringTokenizer(lineTMP.toString(), ","); columnName = strTk.nextToken(); StringBuffer _strBuf = new StringBuffer(); while (strTk.hasMoreTokens()) { _strBuf.append(strTk.nextToken() + ","); } _mhm.put(columnName, _strBuf); } return _mhm; }
From source file:com.cloudera.nav.sdk.examples.lineage3.LineageExport.java
private HttpURLConnection createHttpConnection(ClientConfig config, Set<String> entityIds) throws IOException { String navUrl = config.getNavigatorUrl(); String serverUrl = navUrl + (navUrl.endsWith("/") ? LINEAGE_EXPORT_API : "/" + LINEAGE_EXPORT_API); String queryParamString = String.format(LINEAGE_EXPORT_API_QUERY_PARAMS, URLEncoder.encode(direction, charset), // direction of lineage URLEncoder.encode(length, charset), // length of lineage URLEncoder.encode(lineageOptions, charset)); // Apply all filters URL url = new URL(serverUrl + queryParamString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); String userpass = config.getUsername() + ":" + config.getPassword(); String basicAuth = "Basic " + new String(Base64.encodeBase64(userpass.getBytes())); conn.addRequestProperty("Authorization", basicAuth); conn.addRequestProperty("Content-Type", "application/json"); conn.addRequestProperty("Accept", "application/json"); conn.setReadTimeout(0);//from ww w.j a v a2 s.c o m conn.setRequestMethod("POST"); // entityIds to pass in the request body String postData = constructEntityIdsAsCSV(entityIds); postData = "[" + postData + "]"; byte[] postDataBytes = postData.toString().getBytes("UTF-8"); conn.addRequestProperty("Content-Length", "" + Integer.toString(postData.getBytes().length)); conn.setDoOutput(true); conn.getOutputStream().write(postDataBytes); return conn; }
From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.tipoDato.TextV.java
public String validarTrama(String trama) { if (trama.length() > 1) { //String resultado=""; if (trama.charAt(trama.length() - 1) == limitador.charAt(0)) { trama = trama.toString().substring(0, trama.toString().length() - 1); }//from w ww. java2 s . c o m if (!(trama.charAt(0) == limitador.charAt(0))) { trama = limitador + trama; } //return trama; } return trama; }