List of usage examples for org.apache.commons.io Charsets UTF_8
Charset UTF_8
To view the source code for org.apache.commons.io Charsets UTF_8.
Click Source Link
Eight-bit Unicode Transformation Format.
From source file:io.druid.data.input.impl.AbstractTextFilesFirehoseFactory.java
@Override public Firehose connect(StringInputRowParser firehoseParser, File temporaryDirectory) throws IOException { if (objects == null) { objects = ImmutableList.copyOf(Preconditions.checkNotNull(initObjects(), "initObjects")); }//from ww w. j a v a 2 s . c o m final Iterator<T> iterator = objects.iterator(); return new FileIteratingFirehose(new Iterator<LineIterator>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public LineIterator next() { if (!hasNext()) { throw new NoSuchElementException(); } final T object = iterator.next(); try { return IOUtils.lineIterator(wrapObjectStream(object, openObjectStream(object)), Charsets.UTF_8); } catch (Exception e) { LOG.error(e, "Exception reading object[%s]", object); throw Throwables.propagate(e); } } }, firehoseParser); }
From source file:com.nesscomputing.hbase.TestHBaseSpill.java
@Test public void testSpillOnEnqueue() { final SpillController spillController = new SpillController("test", hbaseWriterConfig); final HBaseWriter dummyWriter = new HBaseWriter(hbaseWriterConfig, conf, spillController); final Put data = new Put("row".getBytes(Charsets.UTF_8)); data.add("family".getBytes(Charsets.UTF_8), "qualifier".getBytes(Charsets.UTF_8), "Hello, World".getBytes(Charsets.UTF_8)); for (int i = 0; i < queueLength; i++) { dummyWriter.write(data);// w w w. j a va 2 s .c o m Assert.assertEquals(0L, spillController.getSpillsOk()); Assert.assertEquals(0L, spillController.getSpillsFailed()); Assert.assertEquals(i + 1, dummyWriter.getQueueLength()); } dummyWriter.write(data); Assert.assertEquals(1L, spillController.getSpillsOk()); Assert.assertEquals(queueLength + 1, spillController.getOpsEnqSpilled()); }
From source file:io.jexiletools.es.ExileToolsSearchClientTest.java
@Test public void testGrabItemMapping() throws Exception { HttpResponse<String> httpResponse = Unirest.get("http://api.exiletools.com/index/_mapping") .header("Authorization", "DEVELOPMENT-Indexer").asString(); String body = httpResponse.getBody(); File mapping = new File("poe-mapping.json"); FileUtils.writeStringToFile(mapping, body, Charsets.UTF_8); }
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatcherUtils.java
public synchronized static Device[] getDevices(Context context) { ThreadUtils.enforceExecutionOnNonMainThread(); initializePatcher(context);/* w w w .ja va2s.com*/ if (sDevices == null) { File path = new File(getTargetDirectory(context) + File.separator + "devices.json"); try { String json = org.apache.commons.io.FileUtils.readFileToString(path, Charsets.UTF_8); Device[] devices = Device.newListFromJson(json); ArrayList<Device> validDevices = new ArrayList<>(); if (devices != null) { for (Device d : devices) { if (d.validate() == 0) { validDevices.add(d); } } } if (!validDevices.isEmpty()) { sDevices = validDevices.toArray(new Device[validDevices.size()]); } } catch (IOException e) { Log.w(TAG, "Failed to read " + path, e); } } return sDevices; }
From source file:com.cedarsoft.serialization.test.utils.AbstractXmlSerializerMultiTest.java
@Nonnull protected Charset getCharset() { return Charsets.UTF_8; }
From source file:ai.api.RequestTask.java
@Override protected String doInBackground(final String... params) { final String payload = params[0]; if (TextUtils.isEmpty(payload)) { throw new IllegalArgumentException("payload argument should not be empty"); }/* w w w . j a v a2 s . com*/ String response = null; HttpURLConnection connection = null; try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.addRequestProperty("Authorization", "Bearer " + accessToken); connection.connect(); final BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream()); IOUtils.write(payload, outputStream, Charsets.UTF_8); outputStream.close(); final InputStream inputStream = new BufferedInputStream(connection.getInputStream()); response = IOUtils.toString(inputStream, Charsets.UTF_8); inputStream.close(); return response; } catch (final IOException e) { Log.e(TAG, "Can't make request to the Speaktoit AI service. Please, check connection settings and API access token.", e); } finally { if (connection != null) { connection.disconnect(); } } return null; }
From source file:com.qualinsight.plugins.sonarqube.smell.plugin.extension.SmellMeasurer.java
/** * Launches the measuring of a give {@link InputFile}. * * @param inputFile {@link InputFile} to be scanned for {@link Smell} annotation presence. *//*from w w w . ja v a 2 s .c om*/ public void measure(final InputFile inputFile) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Measuring code smells for file '{}'", inputFile.absolutePath()); } final String fileContent = getFileAsString(inputFile.file(), Charsets.UTF_8); measureSmellTypes(inputFile, fileContent); measureSmellDebt(inputFile, fileContent); }
From source file:ch.fihlon.moodini.business.token.control.TokenService.java
@Inject public TokenService(@NotNull final MoodiniConfiguration configuration, @NotNull final UserService userService) { this.configuration = configuration; this.tokenSecret = configuration.getTokenSecret().getBytes(Charsets.UTF_8); this.userService = userService; challengeCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(); }
From source file:de.fhg.iais.asc.oai.localwriter.RepositoryWriter.java
private void writeIds() { StringBuilder xml = new StringBuilder(200); xml.append("<ids"); xml.append(" set=\"").append(this.currentSpec).append("\""); xml.append(">\n"); for (String id : this.idsInSet) { xml.append("\t<id>").append(id).append("</id>\n"); }/*from ww w . ja va2 s.co m*/ xml.append("</ids>"); File file = new File(this.rootDir, this.currentSpec + ".xml"); try { FileUtils.write(file, xml.toString(), Charsets.UTF_8); } catch (IOException e) { throw new DbcException(e); } }
From source file:com.cedarsoft.serialization.test.utils.AbstractJsonSerializerTest2.java
protected void verify(@Nonnull byte[] current, @Nonnull byte[] expectedJson) throws Exception { String expectedAsString = new String(expectedJson, Charsets.UTF_8); if (addTypeInformation()) { try {/* w w w . j a v a2 s . c o m*/ expectedAsString = addTypeInformation(expectedJson); } catch (Exception e) { System.err.println("WARNING. Could not add type information due to " + e.getMessage()); } } JsonUtils.assertJsonEquals(expectedAsString, new String(current, Charsets.UTF_8)); }