List of usage examples for java.nio.charset StandardCharsets UTF_8
Charset UTF_8
To view the source code for java.nio.charset StandardCharsets UTF_8.
Click Source Link
From source file:com.falcon.orca.handlers.SlaveHandler.java
@Override public void handle() { CommandLine commandLine;/*from w ww. ja va 2 s. c o m*/ CommandLineParser commandLineParser = new DefaultParser(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); Options options = createSlaveOptions(); printOnCmd("Welcome to ORCA type help to see what ORCA can do."); try { String command = br.readLine(); while (command != null) { if (!StringUtils.isEmpty(command)) { try { String[] treatedCommandParts = treatCommands(command); commandLine = commandLineParser.parse(options, treatedCommandParts); if (commandLine.hasOption("connect")) { String masterHost; if (commandLine.hasOption("masterHost")) { masterHost = commandLine.getOptionValue("masterHost"); } else { throw new MissingArgumentException("Master host is required to connect"); } Integer masterPort; if (commandLine.hasOption("masterPort")) { masterPort = Integer.valueOf(commandLine.getOptionValue("masterPort")); } else { throw new MissingArgumentException("Master port is required to connect"); } nodeManager = actorSystem.actorOf(NodeManager.props(masterHost, masterPort), "node_manager"); } else if (commandLine.hasOption("disconnect")) { if (nodeManager == null || nodeManager.isTerminated()) { printOnCmd("node is not part of any cluster"); } else { NodeManagerCommand nodeManagerCommand = new NodeManagerCommand(); nodeManagerCommand.setType(NodeManagerCommandType.UNREGISTER_FROM_MASTER); nodeManager.tell(nodeManagerCommand, nodeManager); } } else if (commandLine.hasOption("exit")) { if (nodeManager != null && !nodeManager.isTerminated()) { NodeManagerCommand nodeManagerCommand = new NodeManagerCommand(); nodeManagerCommand.setType(NodeManagerCommandType.EXIT); nodeManager.tell(nodeManagerCommand, nodeManager); } actorSystem.shutdown(); actorSystem.awaitTermination(new FiniteDuration(1, TimeUnit.MINUTES)); break; } else { printOnCmd(printHelpSlaveMode()); } } catch (ParseException pe) { printOnCmd(printHelpSlaveMode()); } } else { printOnCmd("", false); } command = br.readLine(); } } catch (IOException e) { printOnCmd("Failed to read input from command line, please try again."); } }
From source file:com.spectralogic.ds3client.commands.parsers.GetJobToReplicateSpectraS3ResponseParser.java
@Override public GetJobToReplicateSpectraS3Response parseXmlResponse(final WebResponse response) throws IOException { final int statusCode = response.getStatusCode(); if (ResponseParserUtils.validateStatusCode(statusCode, expectedStatusCodes)) { switch (statusCode) { case 200: try (final InputStream inputStream = response.getResponseStream()) { final String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); return new GetJobToReplicateSpectraS3Response(result, this.getChecksum(), this.getChecksumType()); }//from w w w.j a v a 2s . c om default: assert false : "validateStatusCode should have made it impossible to reach this line"; } } throw ResponseParserUtils.createFailedRequest(response, expectedStatusCodes); }
From source file:com.seleritycorp.common.base.http.client.HttpResponse.java
/** * Create HttpResponse from the HttpClient response. * //from w w w . j a va 2 s . c o m * @param response The HttpClient response to create a HttpResponse from. * @throws HttpException if reading the response failed. */ @Inject public HttpResponse(@Assisted org.apache.http.HttpResponse response) throws HttpException { this.statusCode = response.getStatusLine().getStatusCode(); try { HttpEntity entity = response.getEntity(); if (entity != null) { this.body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); } else { this.body = ""; } } catch (ParseException | IOException e) { throw new HttpException("Failed to parse response.", e); } }
From source file:com.spectralogic.ds3client.commands.parsers.GetBlobPersistenceSpectraS3ResponseParser.java
@Override public GetBlobPersistenceSpectraS3Response parseXmlResponse(final WebResponse response) throws IOException { final int statusCode = response.getStatusCode(); if (ResponseParserUtils.validateStatusCode(statusCode, expectedStatusCodes)) { switch (statusCode) { case 200: try (final InputStream inputStream = response.getResponseStream()) { final String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); return new GetBlobPersistenceSpectraS3Response(result, this.getChecksum(), this.getChecksumType()); }/*from w w w .ja v a 2s. c o m*/ default: assert false : "validateStatusCode should have made it impossible to reach this line"; } } throw ResponseParserUtils.createFailedRequest(response, expectedStatusCodes); }
From source file:com.ibm.g11n.pipeline.example.MultiBundleCSVFilter.java
@Override public Map<String, LanguageBundle> parse(InputStream inStream, FilterOptions options) throws IOException, ResourceFilterException { Map<String, LanguageBundleBuilder> builders = new HashMap<String, LanguageBundleBuilder>(); CSVParser parser = CSVParser.parse(inStream, StandardCharsets.UTF_8, CSVFormat.RFC4180.withHeader("module", "key", "value").withSkipHeaderRecord(true)); for (CSVRecord record : parser) { String bundle = record.get(0); String key = record.get(1); String value = record.get(2); LanguageBundleBuilder bundleBuilder = builders.get(bundle); if (bundleBuilder == null) { bundleBuilder = new LanguageBundleBuilder(true); builders.put(bundle, bundleBuilder); }/*from www. j a va 2 s .co m*/ bundleBuilder.addResourceString(key, value); } Map<String, LanguageBundle> result = new TreeMap<String, LanguageBundle>(); for (Entry<String, LanguageBundleBuilder> bundleEntry : builders.entrySet()) { String bundleName = bundleEntry.getKey(); LanguageBundle bundleData = bundleEntry.getValue().build(); result.put(bundleName, bundleData); } return result; }
From source file:uk.ac.kcl.Transform23.java
public static Map<Text, Writable> extractHL7Metadata(String messageString) { InputStream is = new ByteArrayInputStream(messageString.getBytes(StandardCharsets.UTF_8)); Hl7InputStreamMessageIterator iter = new Hl7InputStreamMessageIterator(is); Map<Text, Writable> map = new HashMap<>(); while (iter.hasNext()) { Message next = iter.next();//from ww w . j av a2s . c om Text fieldName = new Text("body"); try { if (!next.printStructure().startsWith("ACK")) { try { map.put(fieldName, new Text(next.printStructure())); } catch (HL7Exception ex) { Logger.getLogger(Transform23.class.getName()).log(Level.SEVERE, null, ex); } try { map.put(new Text("message_time_stamp"), Transform23.getIso8601TimeFromMSH(Transform23.getMSH((AbstractMessage) next))); } catch (HL7Exception ex) { Logger.getLogger(Transform23.class.getName()).log(Level.SEVERE, null, ex); } try { map.put(new Text("pid"), Transform23.getPID((AbstractMessage) next)); } catch (HL7Exception ex) { Logger.getLogger(Transform23.class.getName()).log(Level.SEVERE, null, ex); } } } catch (HL7Exception ex) { Logger.getLogger(Transform23.class.getName()).log(Level.SEVERE, null, ex); } } return map; }
From source file:uk.ac.kcl.Transform231.java
public static Map<Text, Writable> extractHL7Metadata(String messageString) { InputStream is = new ByteArrayInputStream(messageString.getBytes(StandardCharsets.UTF_8)); Hl7InputStreamMessageIterator iter = new Hl7InputStreamMessageIterator(is); Map<Text, Writable> map = new HashMap<>(); while (iter.hasNext()) { Message next = iter.next();//from w ww.j a va2 s .c o m Text fieldName = new Text("body"); try { if (!next.printStructure().startsWith("ACK")) { try { map.put(fieldName, new Text(next.printStructure())); } catch (HL7Exception ex) { Logger.getLogger(Transform231.class.getName()).log(Level.SEVERE, null, ex); } try { map.put(new Text("message_time_stamp"), Transform231.getIso8601TimeFromMSH(Transform231.getMSH((AbstractMessage) next))); } catch (HL7Exception ex) { Logger.getLogger(Transform231.class.getName()).log(Level.SEVERE, null, ex); } try { map.put(new Text("pid"), Transform231.getPID((AbstractMessage) next)); } catch (HL7Exception ex) { Logger.getLogger(Transform231.class.getName()).log(Level.SEVERE, null, ex); } } } catch (HL7Exception ex) { Logger.getLogger(Transform231.class.getName()).log(Level.SEVERE, null, ex); } } return map; }
From source file:com.searchcode.app.util.AESEncryptor.java
private void setKey(String key) { this.key = DigestUtils.sha1Hex(key).substring(0, 16).getBytes(StandardCharsets.UTF_8); }
From source file:io.github.swagger2markup.internal.component.ContactInfoComponentTest.java
@Test public void testVersionInfoComponent() throws URISyntaxException { Contact contact = new Contact().name("TestName").email("test@test.de"); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new ContactInfoComponent(context).apply(markupDocBuilder, ContactInfoComponent.parameters(contact, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); }
From source file:at.ac.tuwien.dsg.depic.common.repository.ElasticProcessRepositoryManager.java
public void storeQoRAndPrimitiveActionMeatadata(String edaas, String qor, String primitiveActionMetadata, DBType type) {//from w w w . j a va 2s .c o m InputStream qorStream = new ByteArrayInputStream(qor.getBytes(StandardCharsets.UTF_8)); InputStream elasticityProcessesStream = new ByteArrayInputStream( primitiveActionMetadata.getBytes(StandardCharsets.UTF_8)); List<InputStream> listOfInputStreams = new ArrayList<InputStream>(); listOfInputStreams.add(qorStream); listOfInputStreams.add(elasticityProcessesStream); String sql = "INSERT INTO InputSpecification (name, qor, elasticity_process_config, type) VALUES ('" + edaas + "',?,?,'" + type.getDBType() + "')"; connectionManager.ExecuteUpdateBlob(sql, listOfInputStreams); }