<commit_before>package com.odong.buddhismhomework.models;

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

import com.odong.buddhismhomework.BuildConfig;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;

/**
 * Created by flamen on 15-2-8.
 */
public class CacheFile {


    public CacheFile(Context context, String name) {
        this.name = name;
        this.context = context;
    }


    public String read() throws IOException {
        FileInputStream fis = context.openFileInput(getRealName());
        Log.d("读取缓存", getRealName());
        StringBuilder sb = new StringBuilder();
        byte[] buf = new byte[1024];
        int n;
        while ((n = fis.read(buf)) > 0) {
            sb.append(new String(buf, 0, n));
        }
        return sb.toString();
    }

    public void remove() {
        context.deleteFile(getRealName());
        Log.d("删除文件", getRealName());
    }

    public void sync(boolean redo) throws IOException {
        if (!redo && exists()) {
            return;
        }

        URL url = new URL(
                (BuildConfig.DEBUG ?
                        "http://192.168.1.102/tools/downloads/" :
                        "https://raw.githubusercontent.com/chonglou/BuddhismHomework/master/tools/mp3/")

                        + name);
        Log.d("下载", url.toString() + " => " + getRealName());
        DataInputStream dis = new DataInputStream(url.openStream());

        byte[] buf = new byte[1024];
        int len;

        FileOutputStream fos = context.openFileOutput(getRealName(), Context.MODE_PRIVATE);
        while ((len = dis.read(buf)) > 0) {
            fos.write(buf, 0, len);
        }
        fos.flush();

    }

    public String getRealName() {
        return "cache-" + name;
    }

    public boolean exists() {
        return context.getFileStreamPath(getRealName()).exists();
    }

    private String name;
    private Context context;


}
<commit_msg>fix download url bug<commit_after>package com.odong.buddhismhomework.models;

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

import com.odong.buddhismhomework.BuildConfig;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;

/**
 * Created by flamen on 15-2-8.
 */
public class CacheFile {


    public CacheFile(Context context, String name) {
        this.name = name;
        this.context = context;
    }


    public String read() throws IOException {
        FileInputStream fis = context.openFileInput(getRealName());
        Log.d("读取缓存", getRealName());
        StringBuilder sb = new StringBuilder();
        byte[] buf = new byte[1024];
        int n;
        while ((n = fis.read(buf)) > 0) {
            sb.append(new String(buf, 0, n));
        }
        return sb.toString();
    }

    public void remove() {
        context.deleteFile(getRealName());
        Log.d("删除文件", getRealName());
    }

    public void sync(boolean redo) throws IOException {
        if (!redo && exists()) {
            return;
        }

        URL url = new URL(
                (BuildConfig.DEBUG ?
                        "http://192.168.1.102/tools/downloads/" :
                        "https://raw.githubusercontent.com/chonglou/BuddhismHomework/master/tools/downloads/")

                        + name);
        Log.d("下载", url.toString() + " => " + getRealName());
        DataInputStream dis = new DataInputStream(url.openStream());

        byte[] buf = new byte[1024];
        int len;

        FileOutputStream fos = context.openFileOutput(getRealName(), Context.MODE_PRIVATE);
        while ((len = dis.read(buf)) > 0) {
            fos.write(buf, 0, len);
        }
        fos.flush();

    }

    public String getRealName() {
        return "cache-" + name;
    }

    public boolean exists() {
        return context.getFileStreamPath(getRealName()).exists();
    }

    private String name;
    private Context context;


}

{'fraction_non_alphanumeric': 0.12797254228977692, 'fraction_numerical': 0.012993380730571219, 'mean_word_length': 2.1627906976744184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1564937', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1185, 'n_words': 265}