Tag Archives: Easy Click

[How to Solve] Easyclick read text garbled

Easyclick read text garbled solution

This problem is caused by the forced reading of text encoded as UTF-8 after the upgrade of easyclick
for example,

terms of settlement

    1. write and read Java plug-ins in your own way. After modifying the encoding of the text to UTF-8, it can be read normally</ ol>

Java plug-in code


package com.plugin.gudcgukOhj;

import android.content.Context;
import android.os.Environment;
import android.util.Log;

import java.io.*;
import java.nio.charset.Charset;

public class PluginClz {
    Context context;

    public PluginClz(Context context) {
        System.out.println("--- " + context);
    }  
        /**
	     * Read the local text content to the specified encoding type
	     * @param strFilePath Full name of the text path
	     * @param encode encoding type
	     * @return
	     */
    public static String ReadTxtFile(String strFilePath ,String encode) {
        String path = strFilePath;
        String content = ""; 
        //open
        File file = new File(path);
        if (!file.isDirectory()) {
            try {
                InputStream instream = new FileInputStream(file);
                InputStreamReader inputStreamReader = null;
                try {
                    inputStreamReader = new InputStreamReader(instream, encode);
                } catch (UnsupportedEncodingException e1) {
                    e1.printStackTrace();
                }
                BufferedReader reader = new BufferedReader(inputStreamReader);
                StringBuffer sb = new StringBuffer("");
                String line;
                try {
                    while ((line = reader.readLine()) != null) {
                        sb.append(line);
                        sb.append("\n");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                content = sb.toString();
            } catch (java.io.FileNotFoundException e) {
               System.ou.println("TestFile", "The File doesn't not exist.");
            }
        }
        return content;
    }
}    

Calling method main.js

//The call here is made by loading the apk file first and then instantiating the object
// the js file package will not enter the plug-in, for testing purposes only
function main() {
  //this is where the plugin is loaded
  var r = loadDex("mokuai.apk");
  if (!r) {
      loge("failed to load the plugin");
      return;
  } else {
      logd("Loading the plugin was successful");
  }


  //Here the object is instantiated, and then the relevant method is called
  var obj = new com.plugin.gudcgukOhj.PluginClz(context);
  let file = "/sdcard/1.txt"
  let encode = "GB18030"; // Specify your original encoding
  var s = obj.ReadTxtFile(file,encode);
  logd("java return data: "+s);

}

main();