Java字符串在打印时终止

时间:2014-05-22 10:07:40

标签: java android

我有一个包含大量数据的字符串

String string = "afsa fd fdsfdsfdsfdsfdsfds fdsfds fdsf dsfds fdsfds fdsf dsfdsf dsfdsfsdfsdf  JsonStr [{\"apk_name\":\"Android System\",\"apk_package\":\"android\",\"apk_versioncode\":17},{\"apk_name\":\"Bubble\",\"apk_package\":\"bz.ktk.bubble\",\"apk_versioncode\":21},{\"apk_name\":\"Kingsoft Office\",\"apk_package\":\"cn.wps.moffice_eng\",\"apk_versioncode\":74},{\"apk_name\":\"Math Workout\",\"apk_package\":\"com.akbur.mathsworkout\",\"apk_versioncode\":118},{\"apk_name\":\"Apollo\",\"apk_package\":\"com.andrew.apollo\",\"apk_versioncode\":2},{\"apk_name\":\"Tags\",\"apk_package\":\"com.android.apps.tag\",\"apk_versioncode\":101},{\"apk_name\":\"com.android.backupconfirm\",\"apk_package\":\"com.android.backupconfirm\",\"apk_versioncode\":17},{\"apk_name\":\"Bluetooth Share\",\"apk_package\":\"com.android.bluetooth\",\"apk_versioncode\":17},{\"apk_name\":\"Browser\",\"apk_package\":\"com.android.browser\",\"apk_versioncode\":17},{\"apk_name\":\"Calculator\",\"apk_package\":\"com.android.calculator2\",\"apk_versioncode\":17},{\"apk_name\":\"Calendar\",\"apk_package\":\"com.android.calendar\",\"apk_versioncode\":17},{\"apk_name\":\"Cell Broadcasts\",\"apk_package\":\"com.android.cellbroadcastreceiver\",\"apk_versioncode\":17},{\"apk_name\":\"Certificate Installer\",\"apk_package\":\"com.android.certinstaller\",\"apk_versioncode\":17},{\"apk_name\":\"Chrome\",\"apk_package\":\"com.android.chrome\",\"apk_versioncode\":1916122},{\"apk_name\":\"Contacts\",\"apk_package\":\"com.android.contacts\",\"apk_versioncode\":17},{\"apk_name\":\"Package Access Helper\",\"apk_package\":\"com.android.defcontainer\",\"apk_versioncode\":17},{\"apk_name\":\"Clock\",\"apk_package\":\"com.android.deskclock\",\"apk_versioncode\":203},{\"apk_name\":\"Dev Tools\",\"apk_package\":\"com.android.development\",\"apk_versioncode\":1},{\"apk_name\":\"Basic Daydreams\",\"apk_package\":\"com.android.dreams.basic\",\"apk_versioncode\":17},{\"apk_name\":\"Photo Screensavers\",\"apk_package\":\"com.android.dreams.phototable\",\"apk_versioncode\":17},{\"apk_name\":\"Email\",\"apk_package\":\"com.android.email\",\"apk_versioncode\":410000},{\"apk_name\":\"Exchange Services\",\"apk_package\":\"com.android.exchange\",\"apk_versioncode\":500000},{\"apk_name\":\"Face Unlock\",\"apk_package\":\"com.android.facelock\",\"apk_versioncode\":17},{\"apk_name\":\"Black Hole\",\"apk_package\":\"com.android.galaxy4\",\"apk_versioncode\":1},{\"apk_name\":\"Gallery\",\"apk_package\":\"com.android.gallery3d\",\"apk_versioncode\":40001},{\"apk_name\":\"HTML Viewer\",\"apk_package\":\"com.android.htmlviewer\",\"apk_versioncode\":17},{\"apk_name\":\"Input Devices\",\"apk_package\":\"com.android.inputdevices\",\"apk_versioncode\":17},{\"apk_name\":\"Android keyboard (AOSP)\",\"apk_package\":\"com.android.inputmethod.latin\",\"apk_versioncode\":17},{\"apk_name\":\"Key Chain\",\"apk_package\":\"com.android.keychain\",\"apk_versioncode\":17},{\"apk_name\":\"Fused Location\",\"apk_package\":\"com.android.location.fused\",\"apk_versioncode\":17},{\"apk_name\":\"Magic Smoke Wallpapers\",\"apk_package\":\"com.android.magicsmoke\",\"apk_versioncode\":17},{\"apk_name\":\"Messaging\",\"apk_package\":\"com.android.mms\",\"apk_versioncode\":17},{\"apk_name\":\"Music Visualization Wallpapers\",\"apk_package\":\"com.android.musicvis\",\"apk_versioncode\":17},{\"apk_name\":\"Nfc Service\",\"apk_package\":\"com.android.nfc\",\"apk_versioncode\":17},{\"apk_name\":\"Bubbles\",\"apk_package\":\"com.android.noisefield\",\"apk_versioncode\":1},{\"apk_name\":\"Package installer\",\"apk_package\":\"com.android.packageinstaller\",\"apk_versioncode\":17},{\"apk_name\":\"Phase Beam\",\"apk_package\":\"com.android.phasebeam\",\"apk_versioncode\":1},{\"apk_name\":\"Phone\",\"apk_package\":\"com.android.phone\",\"apk_versioncode\":17},{\"apk_name\":\"Search Applications Provider\",\"apk_package\":\"com.android.providers.applications\",\"apk_versioncode\":17},{\"apk_name\":\"Calendar Storage\",\"apk_package\":\"com.android.providers.calendar\",\"apk_versioncode\":17},{\"apk_name\":\"Contacts Storage\",\"apk_package\":\"com.android.providers.contacts\",\"apk_versioncode\":17},{\"apk_name\":\"Download Manager\",\"apk_package\":\"com.android.providers.downloads\",\"apk_versioncode\":17},{\"apk_name\":\"Downloads\",\"apk_package\":\"com.android.providers.downloads.ui\",\"apk_versioncode\":17},{\"apk_name\":\"DRM Protected Content Storage\",\"apk_package\":\"com.android.providers.drm\",\"apk_versioncode\":17},{\"apk_name\":\"Media Storage\",\"apk_package\":\"com.android.providers.media\",\"apk_versioncode\":511},i am still testing this :) ";

当我打印此字符串时

    System.out.println(TAG + string);

字符串在控制台上被截断,为什么会这样?

1 个答案:

答案 0 :(得分:2)

System.out被重定向到logcat。 Logcat消息的最大长度约为1k,并且会截断额外的字符。

如果您需要记录更长的消息,请使用您自己的日志记录/文件写入解决方案。