Welcome to My Blog

Read my posts in English or Bahasa

File Downloading in Headless Chrome Using ChromeDriver and Hound

Recently, I am making a simple Elixir application performing some actions to a website in an automated way.

The automated testing tool is a perfect candidate to be used to help to build application like that. I use Hound as browser automation library and Chrome as a controlled browser. For the browser driver, I use ChromeDriver.

How to Update Pomera DM100 Firmware

Pomera DM100 is a distraction-free digital writing tool. Think mini laptop with only text editor application loaded.

It comes from Japan. It means its manual is in all Japanese. It becomes hard when you want to do the crucial procedure (like upgrading firmware) AND Google Translate doesn’t help you much.

I can only follow some steps in its updating guide web page and the rest of important steps in PDF are not translatable by Google Translate.

In the end, I have successfully updated my Pomera DM100 to the latest firmware.

Here are the steps:

Java: How To Autodetect The Charset Encoding of A Text File and Remove Byte Order Mark (BOM)

Required dependencies (pom.xml) :

<dependency>
    <groupId>com.ibm.icu</groupId>
    <artifactId>icu4j</artifactId>
    <version>60.1</version>
</dependency>
<dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.6</version>
</dependency>

Autodetect the charset encoding of a text file or input stream then ‘remove’ (skip) Byte Order Mark (BOM) while reading based on detected charset :

File inputFile = new File("/Users/fahri/Downloads/UNKNOWN_TEXT.txt");

BOMInputStream bomInputStream = new BOMInputStream(new BufferedInputStream(new FileInputStream(inputFile)),
        ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_32BE, ByteOrderMark.UTF_32LE);

System.out.println("HAS BOM : " + bomInputStream.hasBOM());

CharsetDetector detector = new CharsetDetector();
detector.setText(bomInputStream);

CharsetMatch charsetMatch = detector.detect();
System.out.println("CHARSET MATCH : " + charsetMatch.getName());

BufferedReader br = new BufferedReader(new InputStreamReader(bomInputStream, charsetMatch.getName()));
for (String line = br.readLine(); line != null; line = br.readLine()) {
    System.out.println(line);
}
br.close();