Example usage for android.util Log d

List of usage examples for android.util Log d

Introduction

In this page you can find the example usage for android.util Log d.

Prototype

public static int d(String tag, String msg) 

Source Link

Document

Send a #DEBUG log message.

Usage

From source file:Main.java

public static void close(Closeable c) {
    if (c != null) {
        try {//from  w  w w  . j  a  v a  2  s  . c  o m
            c.close();
        } catch (IOException ex) {
            Log.d("Trouble closing connection", ex.getMessage());
        }
    }
}

From source file:Main.java

public static void copyFile(String sourceFile, String desFile) {

    Log.d("TAG", "copyFile source file path : " + sourceFile);
    Log.d("TAG", "copyFile des file path : " + desFile);
    Log.d("TAG", "copyFile result is : " + do_exec("cp -f " + sourceFile + " " + desFile));
}

From source file:Main.java

public static void buildLink(TextView view, String url) {
    Log.d(TAG, "buildLink(view = " + view + ", url = " + url + ")");

    StringBuilder sb = new StringBuilder();
    sb.append("<a href='").append(url).append("'>").append(view.getText()).append("</a>");
    view.setText(Html.fromHtml(sb.toString()));
    view.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:Main.java

public static byte[] readZipEntry(File zfile, ZipEntry entry) throws ZipException, IOException {
    Log.d("file3: ", zfile.toString());
    Log.d("zipEntry3: ", entry.toString());
    ZipFile zipFile = new ZipFile(zfile);
    if (entry != null && !entry.isDirectory()) {
        byte[] barr = new byte[(int) entry.getSize()];
        int read = 0;
        int len = 0;
        InputStream is = zipFile.getInputStream(entry);
        BufferedInputStream bis = new BufferedInputStream(is);
        int length = barr.length;
        while ((len = bis.read(barr, read, length - read)) != -1) {
            read += len;/*from   w w w. j  a  v a2  s. c o m*/
        }
        bis.close();
        is.close();
        zipFile.close();
        return barr;
    } else {
        zipFile.close();
        return new byte[0];
    }
}

From source file:Main.java

public static void writeContentToFile(String fileName, String contents) throws IOException {
    Log.d("writeContentToFile", fileName);
    File f = new File(fileName);
    f.getParentFile().mkdirs();//  w w  w . ja v  a  2 s  .  c om
    File tempFile = new File(fileName + ".tmp");
    FileWriter fw = new FileWriter(tempFile);
    BufferedWriter bw = new BufferedWriter(fw);
    int length = contents.length();
    if (length > 0) {
        bw.write(contents);
        //         int apart =  Math.min(length, 65536);
        //         int times = length / apart;
        //         for (int i = 0; i < times; i++) {
        //            bw.write(contents, i * apart, apart);
        //         }
        //         if (length % apart != 0) {
        //            bw.write(contents, times * apart, length - times * apart);
        //         }
        bw.flush();
        fw.flush();
        bw.close();
        fw.close();
        f.delete();
        tempFile.renameTo(f);
    }
}

From source file:Main.java

private static String getFileName(Context context, Uri uri) {
    Log.d("suka", uri.getScheme() + " : " + context.getContentResolver().getType(uri));
    String result = null;/*from   w w  w. j  ava 2 s.c  om*/
    if (uri.getScheme().equals("content")) {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } finally {
            cursor.close();
        }
    }
    if (result == null) {
        Log.d("suka", "res " + uri.getPath());
        result = uri.getPath();
        int cut = result.lastIndexOf('/');
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}

From source file:Main.java

/**
 * Clears the already stored file./*from  www .  java 2s .com*/
 */
public static void clearFileCache(String filename) {
    File file = new File(filename);

    if (file.exists() && file.delete()) {
        Log.d("GIJON", "Fichero local " + filename + " borrado");
    }
    return;
}

From source file:Main.java

public static BufferedReader runBufferedCommand(String cmd) throws IOException {
    Log.d(TAG, "Executing: " + cmd);
    Process process = Runtime.getRuntime().exec(cmd);
    BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
    return reader;
}

From source file:Main.java

/**
 * Writes long strings to the logcat.//from  w  ww .j  av  a  2s  . c  o m
 *
 * @param str The string to write to the logcat.
 */
public static void logLongStrings(String logTag, String str) {
    if (str.length() > 4000) {
        Log.d(logTag, str.substring(0, 4000));
        logLongStrings(logTag, str.substring(4000));
    } else {
        Log.d(logTag, str);
    }
}

From source file:Main.java

static void log(String tag, String msg) {
    Log.d(tag, msg);
}