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.ibm.ws.lars.rest.FrontPage.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType(MediaType.APPLICATION_JSON); resp.setCharacterEncoding(StandardCharsets.UTF_8.name()); PrintWriter printWriter = resp.getWriter(); List<AssetFilter> filters = new ArrayList<>(); filters.add(new AssetFilter("state", Arrays.asList(new Condition[] { new Condition(Operation.EQUALS, "published") }))); int assetCount = serviceLayer.countAllAssets(filters, null); JsonGenerator frontPageJsonGenerator = new JsonFactory().createGenerator(printWriter); frontPageJsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter()); frontPageJsonGenerator.writeStartObject(); frontPageJsonGenerator.writeStringField("serverName", "LARS"); frontPageJsonGenerator.writeNumberField("assetCount", assetCount); frontPageJsonGenerator.writeEndObject(); frontPageJsonGenerator.flush();// w w w.ja va 2s .c om frontPageJsonGenerator.close(); }
From source file:com.github.benmanes.caffeine.cache.simulator.parser.TextTraceReader.java
/** Returns a stream of each line in the trace file. */ protected Stream<String> lines() throws IOException { InputStream input = readFiles(); Reader reader = new InputStreamReader(input, StandardCharsets.UTF_8); return new BufferedReader(reader, 1 << 16).lines().map(String::trim) .onClose(() -> Closeables.closeQuietly(input)); }
From source file:com.haulmont.cuba.core.sys.ResourcesImpl.java
@Override @Nullable/*from w w w. j a va 2s . c om*/ public String getResourceAsString(String location) { InputStream stream = getResourceAsStream(location); if (stream == null) return null; try { return IOUtils.toString(stream, StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(stream); } }
From source file:com.example.api.UrlShortener.java
String getHash(String url) { int hashCode = Hashing.murmur3_32().hashString(url, StandardCharsets.UTF_8).asInt(); String hash = Integer.toHexString(hashCode); urlMap.putIfAbsent(hash, url);/*from w w w . j a va2s. com*/ return hash; }
From source file:com.synopsys.integration.blackduck.service.BlackDuckJsonTransformerTest.java
@Test public void testConstructionHappyPath() throws Exception { InputStream jsonInputStream = getClass().getResourceAsStream("/projectViewResponse.json"); String json = IOUtils.toString(jsonInputStream, StandardCharsets.UTF_8); ProjectView projectView = BlackDuckJsonTransformerTest.blackDuckJsonTransformer.getResponseAs(json, ProjectView.class); assertFalse(StringUtils.isBlank(projectView.getDescription())); assertObjectValid(projectView);/* w ww . j a va2 s . com*/ assertJsonValid(json, projectView); }
From source file:cz.cas.lib.proarc.common.workflow.PhysicalMaterialBuilderTest.java
@Test public void testBuild() throws Exception { CatalogConfiguration c = new CatalogConfiguration("testCatalogId", "", new BaseConfiguration() { {/* w w w.j a va 2s . c o m*/ addProperty(CatalogConfiguration.PROPERTY_URL, "tcp://localhost:9991"); addProperty(CatalogConfiguration.PROPERTY_NAME, "test"); addProperty(CatalogConfiguration.PROPERTY_TYPE, Z3950Catalog.TYPE); } }); String xml = IOUtils.toString(WorkflowManagerTest.class.getResource("rdczmods.xml"), StandardCharsets.UTF_8); PhysicalMaterial pm = new PhysicalMaterialBuilder().build(xml, c); assertEquals(xml, pm.getMetadata()); assertEquals(c.getUrl(), pm.getSource()); assertEquals("Nov vlna = : La nouvelle vague : Truffaut, Godard, Chabrol, Rohmer, Rivette", pm.getLabel()); }
From source file:com.collective.celos.servlet.RegisterServlet.java
protected void doPut(HttpServletRequest req, HttpServletResponse res) throws ServletException { try {// ww w . java 2 s .co m BucketID bucket = getRequestBucketID(req); RegisterKey key = getRequestKey(req); JsonNode value = Util.JSON_READER .readTree(new InputStreamReader(req.getInputStream(), StandardCharsets.UTF_8)); try (StateDatabaseConnection connection = getStateDatabase().openConnection()) { connection.putRegister(bucket, key, value); } } catch (Exception e) { throw new ServletException(e); } }
From source file:com.evolveum.midpoint.repo.sql.util.OrgStructGenerator.java
@Test(enabled = false) public void generateOrgStructure() throws Exception { List<OrgType> orgs = generateOrgStructure(0, new int[] { 1, 20, 25, 2 }, "Org", null); System.out.println(orgs.size()); Collections.shuffle(orgs);//from w ww.j a v a2s. com File file = new File("./target/orgs.xml"); if (file.exists()) { file.delete(); } file.createNewFile(); try (Writer writer = new FileWriterWithEncoding(file, StandardCharsets.UTF_8)) { writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"); writer.write("<objects xmlns=\"http://midpoint.evolveum.com/xml/ns/public/common/common-3\">\n"); for (OrgType org : orgs) { writer.write(PrismTestUtil.serializeObjectToString(org.asPrismObject())); } writer.write("</objects>"); } }
From source file:ee.ria.xroad.monitor.executablelister.PackageListerTest.java
/** * Before test handler/*from ww w .jav a2 s . c o m*/ */ @Before public void setup() throws Exception { packageOutputString = FileUtils.readFileToString(new File(RESOURCE_PATH + "ubuntu-packagelist.txt"), StandardCharsets.UTF_8.toString()); log.info("string=" + packageOutputString); }
From source file:io.github.swagger2markup.internal.component.ConsumesComponentTest.java
@Test public void testConsumesComponent() throws URISyntaxException { List<String> consumes = new ArrayList<>(); consumes.add("application/json"); consumes.add("application/xml"); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new ConsumesComponent(context).apply(markupDocBuilder, ConsumesComponent.parameters(consumes, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); }