skip to Main Content

In the Android Studio program, when printing the object, it is cut off due to the length of the data. How can I print the matrix without any cuting?

enter image description here

2

Answers


  1. On the left side of the Logcat window enable the Soft-Wrap:

    enter image description here

    Login or Signup to reply.
  2. To print a lengthy string in logcat, use this piece of code. Here s is the string which is to be printed. I tried this code where s is given as a sample text of 1000 words and was successfully displayed Logcat.

    In java,

    final int maxSize = 2048;
    for (int i = 0; i < s.length(); i += maxSize) {
        Log.d("largeString", s.substring(i, Math.min(s.length(), i + maxSize)));
    }
    

    In Kotlin,

    val maxSize = 2048
    var i = 0
    while (i < s.length) {
        Log.d("yeyey", s.substring(i, Math.min(s.length, i + maxSize)))
        i += maxSize
    }
    

    Try this code and hope this works for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search