java.nio.charset.Charset Java Examples

The following examples show how to use java.nio.charset.Charset. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUtf8.java    From Tomcat7.0.67 with Apache License 2.0 7 votes vote down vote up
@Test
public void testJvmDecoder() {
    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
    int testCount = 0;
    try {
        for (Utf8TestCase testCase : TEST_CASES) {
            doTest(decoder, testCase, testCase.flagsJvm);
            testCount++;
        }
    } finally {
        System.err.println("Workarounds added to " + workAroundCount +
                " tests to account for known JVM bugs");
        if (testCount < TEST_CASES.size()) {
            System.err.println("Executed " + testCount + " of " +
                    TEST_CASES.size() + " UTF-8 tests before " +
                    "encountering a failure");
        }
    }
}
 
Example #2
Source File: PluginLoaderImplTest.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
@Test
public void test_load_plugins_folder_contains_jar_file() throws Exception {
    final File pluginsFolder = temporaryFolder.newFolder("extension");
    final File pluginFolder = temporaryFolder.newFolder("extension", "plugin1");
    final File file = new File(pluginFolder, "extension.jar");
    FileUtils.writeStringToFile(pluginFolder.toPath().resolve("hivemq-extension.xml").toFile(),
            validPluginXML1,
            Charset.defaultCharset());
    final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class).
            addAsServiceProviderAndClasses(ExtensionMain.class, TestExtensionMainImpl.class);

    javaArchive.as(ZipExporter.class).exportTo(file);

    when(classServiceLoader.load(eq(ExtensionMain.class), any(ClassLoader.class))).thenReturn(new ArrayList<>());

    pluginLoader.loadPlugins(pluginsFolder.toPath(), false, ExtensionMain.class);

    //Let's verify that the extension was loaded
    verify(classServiceLoader).load(any(Class.class), any(ClassLoader.class));
}
 
Example #3
Source File: FileRecordReader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<Record> out = new ArrayList<>();

    for (RecordMetaData meta : recordMetaDatas) {
        URI uri = meta.getURI();

        List<Writable> list;
        try(InputStream s = streamCreatorFn.apply(uri)) {
            list = loadFromStream(uri, s, Charset.forName(charset));
        } catch (IOException e){
            throw new RuntimeException("Error reading from stream for URI: " + uri);
        }

        out.add(new org.datavec.api.records.impl.Record(list, meta));
    }

    return out;
}
 
Example #4
Source File: GeoJsonParser.java    From ground-android with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the immutable list of tiles specified in {@param geojson} that intersect {@param
 * bounds}.
 */
public ImmutableList<Tile> intersectingTiles(LatLngBounds bounds, File file) {
  try {
    String fileContents = FileUtils.readFileToString(file, Charset.forName(JSON_SOURCE_CHARSET));
    // TODO: Separate parsing and intersection checks, make asyc (single, completable).
    JSONObject geoJson = new JSONObject(fileContents);
    // TODO: Make features constant.
    JSONArray features = geoJson.getJSONArray(FEATURES_KEY);

    return stream(toArrayList(features))
        .map(GeoJsonTile::new)
        .filter(tile -> tile.boundsIntersect(bounds))
        .map(this::jsonToTile)
        .collect(toImmutableList());

  } catch (JSONException | IOException e) {
    Log.e(TAG, "Unable to parse JSON", e);
  }

  return ImmutableList.of();
}
 
Example #5
Source File: DocumentTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testShiftJisRoundtrip() throws Exception {
    String input =
            "<html>"
                    +   "<head>"
                    +     "<meta http-equiv=\"content-type\" content=\"text/html; charset=Shift_JIS\" />"
                    +   "</head>"
                    +   "<body>"
                    +     "before&nbsp;after"
                    +   "</body>"
                    + "</html>";
    InputStream is = new ByteArrayInputStream(input.getBytes(Charset.forName("ASCII")));

    Document doc = Jsoup.parse(is, null, "http://example.com");
    doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);

    String output = new String(doc.html().getBytes(doc.outputSettings().charset()), doc.outputSettings().charset());

    assertFalse("Should not have contained a '?'.", output.contains("?"));
    assertTrue("Should have contained a '&#xa0;' or a '&nbsp;'.",
            output.contains("&#xa0;") || output.contains("&nbsp;"));
}
 
Example #6
Source File: ClassType.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Override
public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
    if( !(val instanceof  ITypedReferenceableInstance)) {
        throw new IllegalArgumentException("Unexpected value type " + val.getClass().getSimpleName() + ". Expected instance of ITypedStruct");
    }
    digester.update(getName().getBytes(Charset.forName("UTF-8")));

    if(fieldMapping.fields != null && val != null) {
        IReferenceableInstance typedValue = (IReferenceableInstance) val;
        if(fieldMapping.fields.values() != null) {
            for (AttributeInfo aInfo : fieldMapping.fields.values()) {
                Object attrVal = typedValue.get(aInfo.name);
                if (attrVal != null) {
                    aInfo.dataType().updateSignatureHash(digester, attrVal);
                }
            }
        }
    }
}
 
Example #7
Source File: ArchiveSerializer.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
/**
 * 计算消费日志占用的长度
 * <br>
 * (byte[]:messageId, int:brokerId, byte[16]:clientIP, long:consumeTime, String:app(变长), )
 *
 * @param consumeLog
 * @return
 */
private static int consumeLogSize(ConsumeLog consumeLog) {
    int size = 0;
    // messageId
    size += consumeLog.getBytesMessageId().length;
    // brokerId
    size += 4;
    // clientIp
    size += 16;
    // consumeTime
    size += 8;
    // app长度
    size += 2;
    // app
    size += consumeLog.getApp().getBytes(Charset.forName("utf-8")).length;
    return size;
}
 
Example #8
Source File: NettyHttpServletResponse.java    From spring-boot-starter-netty with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setContentType(String type) {
    if (isCommitted()) {
        return;
    }
    if (hasWriter()) {
        return;
    }
    if (null == type) {
        contentType = null;
        return;
    }
    MediaType mediaType = MediaType.parse(type);
    Optional<Charset> charset = mediaType.charset();
    if (charset.isPresent()) {
        setCharacterEncoding(charset.get().name());
    }
    contentType = mediaType.type() + '/' + mediaType.subtype();
}
 
Example #9
Source File: NiFiSourceMain.java    From flink-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder()
            .url("http://localhost:8080/nifi")
            .portName("Data for Flink")
            .requestBatchCount(5)
            .buildConfig();

    SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig);
    DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2);

    DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() {
        @Override
        public String map(NiFiDataPacket value) throws Exception {
            return new String(value.getContent(), Charset.defaultCharset());
        }
    });

    dataStream.print();
    env.execute();
}
 
Example #10
Source File: DefaultUploadFeatureTest.java    From cyberduck with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testUpload() throws Exception {
    final DefaultUploadFeature<VersionId> m = new DefaultUploadFeature<VersionId>(new GoogleStorageWriteFeature(session));
    final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final String random = new RandomStringGenerator.Builder().build().generate(1000);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out, Charset.defaultCharset());
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setLength(random.getBytes().length);
    m.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
        new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(new GoogleStorageFindFeature(session).find(test));
    final PathAttributes attributes = new GoogleStorageListService(session).list(container,
        new DisabledListProgressListener()).get(test).attributes();
    assertEquals(random.getBytes().length, attributes.getSize());
    new GoogleStorageDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
 
Example #11
Source File: ISO2022_CN_CNS.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Encoder(Charset cs)
{
    super(cs);
    SODesig = "$)G";
    SS2Desig = "$*H";
    SS3Desig = "$+I";

    try {
        Charset cset = Charset.forName("EUC_TW"); // CNS11643
        ISOEncoder = cset.newEncoder();
    } catch (Exception e) { }
}
 
Example #12
Source File: TestGetSchema.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
@Ignore("Does not work on windows")
public void testSchemaFromFileSystem() throws IOException {
    File schemaFile = temp.newFile("schema.avsc");
    FileOutputStream out = new FileOutputStream(schemaFile);
    out.write(bytesFor(SCHEMA.toString(), Charset.forName("utf8")));
    out.close();

    Schema schema = AbstractKiteProcessor.getSchema(
            schemaFile.toString(), DefaultConfiguration.get());

    Assert.assertEquals("Schema from file should match", SCHEMA, schema);
}
 
Example #13
Source File: CheckEncodingPropertiesFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static String checkConvertMime2Java(String xml) {
    final String jName = Encodings.convertMime2JavaEncoding(xml);
    final String jCharsetName;
    try {
        jCharsetName = Charset.forName(jName).name();
    } catch (Exception x) {
        throw new Error("Unrecognized charset returned by Encodings.convertMime2JavaEncoding(\""+xml+"\")", x);
    }
    System.out.println("Encodings.convertMime2JavaEncoding(\""+xml+"\") = \""+jName+"\" ("+jCharsetName+")");
    return jName;
}
 
Example #14
Source File: ToolBox.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void compareLines(Path path, List<String> strings,
        String encoding, boolean trim)
        throws FileNotFoundException, IOException, ResourcesNotEqualException {
    Charset charset = encoding != null ?
            Charset.forName(encoding) :
            defaultCharset;
    List<String> list = Files.readAllLines(path, charset);
    compareLines(list, strings, trim);
}
 
Example #15
Source File: AdminOperationsTest.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
@Test
public void passesIndexTemplateToClient() {

    //given
    HCHttp factory = Mockito.spy(HCHttpTest.createDefaultHttpObjectFactoryBuilder().build());

    HttpClient httpClient = mockedHttpClient(factory);
    AtomicReference<ByteBuf> argCaptor = new AtomicReference<>();
    mockedResult(httpClient, true, argCaptor);

    IndexTemplate indexTemplate = spy(IndexTemplate.newBuilder()
            .withPath("classpath:indexTemplate.json")
            .withName("testName")
            .build());

    String expectedPayload = indexTemplate.getSource();

    // when
    factory.execute(indexTemplate);

    // then
    ArgumentCaptor<IndexTemplateRequest> requestArgumentCaptor = ArgumentCaptor.forClass(IndexTemplateRequest.class);
    verify(httpClient).execute(requestArgumentCaptor.capture(), any());

    assertEquals(argCaptor.get().toString(Charset.forName("UTF-8")), expectedPayload);

}
 
Example #16
Source File: AccountServiceTest.java    From swellrt with Apache License 2.0 5 votes vote down vote up
protected ServletInputStream asServletInputStream(final String data) {
  return new ServletInputStream() {

    ByteArrayInputStream byteInputStream =
        new ByteArrayInputStream(data.getBytes(Charset.forName("UTF-8")));

    int b;

    @Override
    public boolean isFinished() {
      return b == -1;
    }

    @Override
    public boolean isReady() {
      return true;
    }

    @Override
    public void setReadListener(ReadListener readListener) {
    }

    @Override
    public int read() throws IOException {
      this.b = byteInputStream.read();
      return b;
    }

  };
}
 
Example #17
Source File: TestUnauthorizedScripts.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@BeforeClass
public static void before() throws Throwable {
    // initialize the scheduler & rm with a custom authorized script folder

    scriptsFolder = folder.newFolder("scripts");
    File schedulerConfigFile = generateConfigFile(originalSchedulerConfigFile.toURI(), "schedulerConfig");
    File rmConfigFile = generateConfigFile(originalRMConfigFile.toURI(), "rmConfig");

    // create authorized and unauthorized scripts
    String tempFolderPathEscaped = folder.getRoot().getAbsolutePath().replace("\\", "\\\\");
    authorizedForkScriptContent = "new File('" + tempFolderPathEscaped + "','fork_auth.out').write('ok')";
    authorizedCleanScriptContent = "new File('" + tempFolderPathEscaped + "','clean_auth.out').write('ok')";
    authorizedSelectionScriptContent = "new File('" + tempFolderPathEscaped +
                                       "','selection_auth.out').write('ok'); selected=true";

    File forkScript = new File(scriptsFolder, "forkScript");
    FileUtils.write(forkScript, authorizedForkScriptContent, Charset.defaultCharset(), false);
    File cleanScript = new File(scriptsFolder, "cleanScript");
    FileUtils.write(cleanScript, authorizedCleanScriptContent, Charset.defaultCharset(), false);
    File selectionScript = new File(scriptsFolder, "selectionScript");
    FileUtils.write(selectionScript, authorizedSelectionScriptContent, Charset.defaultCharset(), false);

    unauthorizedForkScriptContent = "new File('" + tempFolderPathEscaped + "','fork.out').write('ko')";
    unauthorizedCleanScriptContent = "new File('" + tempFolderPathEscaped + "','clean.out').write('ko')";
    unauthorizedSelectionScriptContent = "new File('" + tempFolderPathEscaped +
                                         "','selection.out').write('ko'); selected=true";

    // start the configured scheduler
    schedulerHelper = new SchedulerTHelper(true,
                                           schedulerConfigFile.getAbsolutePath(),
                                           rmConfigFile.getAbsolutePath(),
                                           null);
}
 
Example #18
Source File: PutCassandraQL.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Determines the CQL statement that should be executed for the given FlowFile
 *
 * @param session  the session that can be used to access the given FlowFile
 * @param flowFile the FlowFile whose CQL statement should be executed
 * @return the CQL that is associated with the given FlowFile
 */

private String getCQL(final ProcessSession session, final FlowFile flowFile, final Charset charset) {
    // Read the CQL from the FlowFile's content
    final byte[] buffer = new byte[(int) flowFile.getSize()];
    session.read(flowFile, new InputStreamCallback() {
        @Override
        public void process(final InputStream in) throws IOException {
            StreamUtils.fillBuffer(in, buffer);
        }
    });

    // Create the PreparedStatement string to use for this FlowFile.
    return new String(buffer, charset);
}
 
Example #19
Source File: ChannelsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testNewWriterWritableByteChannelString() throws IOException {
    this.fouts = new FileOutputStream(tmpFile);
    WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
    Writer testWriter = Channels.newWriter(wbChannel, CODE_SET); //$NON-NLS-1$
    Writer testWriter_s = Channels.newWriter(wbChannel, Charset.forName(
            CODE_SET).newEncoder(), //$NON-NLS-1$
            -1);

    String writebuf = ""; //$NON-NLS-1$
    for (int val = 0; val < this.writebufSize / 2; val++) {
        writebuf = writebuf + ((char) (val + 64));
    }
    byte[] bit = new byte[1];
    bit[0] = 80;
    this.fouts.write(bit);
    this.assertFileSizeSame(tmpFile, 1);

    // writer continues to write after '1',what the fouts write
    testWriter.write(writebuf);
    testWriter.flush();
    this.assertFileSizeSame(tmpFile, this.writebufSize / 2 + 1);
    // testwriter_s does not know if testwrite writes
    testWriter_s.write(writebuf);
    testWriter.flush();
    this.assertFileSizeSame(tmpFile, this.writebufSize / 2 + 1);
    // testwriter_s even does not know if himself writes?
    testWriter_s.write(writebuf);
    testWriter.flush();
    this.assertFileSizeSame(tmpFile, this.writebufSize / 2 + 1);

    // close the fouts, no longer writable for testWriter
    for (int val = 0; val < this.writebufSize; val++) {
        writebuf = writebuf + ((char) (val + 64));
    }
    this.fouts.close();
    testWriter_s.write(writebuf);
    testWriter.flush();
    this.assertFileSizeSame(tmpFile, this.writebufSize / 2 + 1);
}
 
Example #20
Source File: DefaultShapeMetaSetter.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public void set(DbfRecord metadata, Polygon polygon) throws ParseException {
    if (metadata != null) {
        metadata.setStringCharset(Charset.defaultCharset());
        polygon.setSnippet(metadata.toMap().toString());
        polygon.setTitle(getSensibleTitle(polygon.getSnippet()));
    }
    final BoundingBox boundingBox = polygon.getBounds();
    polygon.setSubDescription(boundingBox.toString());
}
 
Example #21
Source File: StatsdReporter.java    From kafka-statsd-reporter with MIT License 5 votes vote down vote up
private void flush() {
	try {
		int sizeOfBuffer = sendBuffer.position();
		if (sizeOfBuffer <= 0) {
			// empty buffer
			return;
		}

		// send and reset the buffer
		sendBuffer.flip();
		int nbSentBytes = channel.send(sendBuffer, address);
		LOG.debug("Send entirely stat :" + new String(sendBuffer.array(), Charset.forName("UTF-8")) + " to host "
				+ address.getHostName() + " : " + address.getPort());
		if (sizeOfBuffer != nbSentBytes) {
			LOG.error("Could not send entirely stat (" + sendBuffer.toString() + ") : "
					+  new String(sendBuffer.array(), Charset.forName("UTF-8")) + " to host "
					+ address.getHostName() + " : " + address.getPort() + ". Only sent " + nbSentBytes
					+ " out of " + sizeOfBuffer);
		}
		sendBuffer.limit(sendBuffer.capacity());
		sendBuffer.rewind();
	} catch (IOException e) {
		LOG.error("Could not send entirely stat (" + sendBuffer.toString() + ") : "
				+  new String(sendBuffer.array(), Charset.forName("UTF-8")) + " to host "
				+ address.getHostName() + " : "	+ address.getPort(), e);
	}
}
 
Example #22
Source File: JSefaReader.java    From incubator-batchee with Apache License 2.0 5 votes vote down vote up
@Override
public void open(final Serializable checkpoint) throws Exception {
    deserializer = initDeserializer();

    Charset charset;
    if (encoding != null && !encoding.isEmpty()) {
        charset = Charset.forName(encoding);
    } else {
        charset = Charset.defaultCharset();
    }

    deserializer.open(new BufferedReader(new InputStreamReader(new FileInputStream(file), charset)));
    super.open(checkpoint);
}
 
Example #23
Source File: StringCoding.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static byte[] encode(Charset cs, char[] ca, int off, int len) {
    CharsetEncoder ce = cs.newEncoder();
    int en = scale(len, ce.maxBytesPerChar());
    byte[] ba = new byte[en];
    if (len == 0)
        return ba;
    boolean isTrusted = false;
    if (System.getSecurityManager() != null) {
        if (!(isTrusted = (cs.getClass().getClassLoader0() == null))) {
            ca =  Arrays.copyOfRange(ca, off, off + len);
            off = 0;
        }
    }
    ce.onMalformedInput(CodingErrorAction.REPLACE)
      .onUnmappableCharacter(CodingErrorAction.REPLACE)
      .reset();
    if (ce instanceof ArrayEncoder) {
        int blen = ((ArrayEncoder)ce).encode(ca, off, len, ba);
        return safeTrim(ba, blen, cs, isTrusted);
    } else {
        ByteBuffer bb = ByteBuffer.wrap(ba);
        CharBuffer cb = CharBuffer.wrap(ca, off, len);
        try {
            CoderResult cr = ce.encode(cb, bb, true);
            if (!cr.isUnderflow())
                cr.throwException();
            cr = ce.flush(bb);
            if (!cr.isUnderflow())
                cr.throwException();
        } catch (CharacterCodingException x) {
            throw new Error(x);
        }
        return safeTrim(ba, bb.position(), cs, isTrusted);
    }
}
 
Example #24
Source File: ClientHandler.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    try {
        ByteBuf buf =(ByteBuf)msg;
        CharSequence text = buf.readCharSequence(buf.readableBytes(),
                Charset.defaultCharset());
        System.out.println(text);
    } finally {
        ReferenceCountUtil.release(msg);
    }
}
 
Example #25
Source File: DataTransferer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether this JRE can both encode and decode text in the
 * specified encoding.
 */
public static boolean isEncodingSupported(String encoding) {
    if (encoding == null) {
        return false;
    }
    try {
        return Charset.isSupported(encoding);
    } catch (IllegalCharsetNameException icne) {
        return false;
    }
}
 
Example #26
Source File: DbgpStream.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@NbBundle.Messages("LBL_PhpDebuggerConsole=PHP Debugger Console")
public void process(DebugSession session, DbgpCommand command) {
    byte[] buffer;
    try {
        buffer = Base64.getDecoder().decode(getNodeValue(getNode()));
    } catch (IllegalArgumentException ex) {
        Logger.getLogger(DbgpStream.class.getName()).log(Level.WARNING, null, ex);
        buffer = new byte[0];
    }
    InputOutput io = IOProvider.getDefault().getIO(Bundle.LBL_PhpDebuggerConsole(), false);
    io.getOut().println(new String(buffer, Charset.defaultCharset()));
    io.getOut().close();
}
 
Example #27
Source File: PrepNextAppLibsRelease.java    From scelight with Apache License 2.0 5 votes vote down vote up
/**
 * @param args used to take arguments from the running environment; args[0] is the name of the app-libs-build.properties file to generate for Ant
 * @throws Exception if any error occurs
 */
public static void main( final String[] args ) throws Exception {
	final String BUILD_INFO_FILE = "/hu/sllibs/r/bean/build-info.xml";
	
	// Read current app-libs build info
	final BuildInfoBean b = JAXB.unmarshal( AR.class.getResource( BUILD_INFO_FILE ), BuildInfoBean.class );
	System.out.println( "Current: " + b );
	
	// Increment build
	b.setBuild( b.getBuildNumber() + 1 );
	b.setDate( new Date() );
	System.out.println( "New: " + b );
	
	// Archive to app-libs-build-history.txt and save new build info
	// to both src-app-libs and bin-app-libs folders (so no refresh is required in Eclipse)
	try ( final BufferedWriter out = Files.newBufferedWriter( Paths.get( "dev-data", "app-libs-build-history.txt" ), Charset.forName( "UTF-8" ),
	        StandardOpenOption.APPEND ) ) {
		out.write( b.getBuildNumber() + " " + b.getDate() );
		out.newLine();
	}
	JAXB.marshal( b, Paths.get( "src-app-libs", BUILD_INFO_FILE ).toFile() );
	JAXB.marshal( b, Paths.get( "bin-app-libs", BUILD_INFO_FILE ).toFile() );
	
	// Create properties file for Ant
	final Properties p = new Properties();
	p.setProperty( "appLibsVer", AConsts.APP_LIBS_VERSION.toString() );
	p.setProperty( "appLibsBuildNumber", b.getBuildNumber().toString() );
	try ( final FileOutputStream out = new FileOutputStream( args[ 0 ] ) ) {
		p.store( out, null );
	}
}
 
Example #28
Source File: StringCoding.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private StringDecoder(Charset cs, String rcn) {
    this.requestedCharsetName = rcn;
    this.cs = cs;
    this.cd = cs.newDecoder()
        .onMalformedInput(CodingErrorAction.REPLACE)
        .onUnmappableCharacter(CodingErrorAction.REPLACE);
    this.isTrusted = (cs.getClass().getClassLoader0() == null);
}
 
Example #29
Source File: JIS_X_0208_Solaris_Decoder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public JIS_X_0208_Solaris_Decoder(Charset cs) {
    super(cs,
          index1,
          index2,
          0x21,
          0x7E);
}
 
Example #30
Source File: LoginServerPackets.java    From MirServer-Netty with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readPacket(ByteBuf in) throws WrongFormatException {
	super.readPacket(in);

	String content = in.toString(Charset.defaultCharset()).trim();

	String[] parts = content.split(CONTENT_SEPARATOR_STR);
	if (parts.length < 3)
		throw new WrongFormatException();
	this.selectServerIp = parts[0];
	this.selectserverPort = Integer.parseInt(parts[1]);
	this.cert = Short.parseShort(parts[2]);
}