如何从键盘获取UTF-8字符或将其删除

时间:2018-05-12 13:38:30

标签: java character-encoding

我正在使用Scanner类,如下所示:

Scanner sc = new Scanner(System.in);
System.out.println(sc.nextLine());

它工作正常,但如果输入包含utf-8字符,则控制台无法读取它们。

那么如何从键盘获取utf-8字符或在没有utf-8的情况下设置输入

非常感谢。

1 个答案:

答案 0 :(得分:1)

尝试指定编码和区域设置:

> > CommandInvokationFailure: Unable to convert classes into dex format.
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/------/Documents/android-sdk-macosx/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
stderr[
trouble writing output: Too many field references to fit in one dex file: 105703; max is 65536.
You may try using multi-dex. If multi-dex is enabled then the list of classes for the main dex list is too large.
References by package:
     3 android.accounts
    28 android.app
    14 android.arch.core.internal
  1895 android.arch.lifecycle
     1 android.bluetooth
     2 android.content
    41 android.content.pm
    10 android.content.res
     3 android.database
    48 android.graphics
     1 android.hardware
     1 android.location
     5 android.media
     1 android.media.browse
     2 android.net
     6 android.net.wifi
    34 android.os
     3 android.print
     2 android.provider
    13 android.support.annotation
  1856 android.support.compat
  1856 android.support.coreui
  1856 android.support.coreutils
  1958 android.support.customtabs
  1856 android.support.fragment
  2062 android.support.graphics.drawable
  1856 android.support.graphics.drawable.animated
  1856 android.support.mediacompat
  1856 android.support.v4
    13 android.support.v4.accessibilityservice
   943 android.support.v4.app
   113 android.support.v4.content
    13 android.support.v4.content.pm
    16 android.support.v4.content.res
    50 android.support.v4.graphics
    57 android.support.v4.graphics.drawable
     4 android.support.v4.hardware.display
    12 android.support.v4.hardware.fingerprint
    11 android.support.v4.internal.view
   428 android.support.v4.media
     8 android.support.v4.media.app
   378 android.support.v4.media.session
     7 android.support.v4.net
    37 android.support.v4.os
    52 android.support.v4.print
    98 android.support.v4.provider
    54 android.support.v4.text
     6 android.support.v4.text.util
   120 android.support.v4.util
   412 android.support.v4.view
   126 android.support.v4.view.accessibility
     8 android.support.v4.view.animation
   478 android.support.v4.widget
   399 android.support.v7.app
  1856 android.support.v7.appcompat
  1856 android.support.v7.cardview
     8 android.support.v7.content.res
    18 android.support.v7.graphics.drawable
     1 android.support.v7.text
    85 android.support.v7.view
   270 android.support.v7.view.menu
   897 android.support.v7.widget
     1 android.system
     6 android.text
     1 android.text.util
    13 android.util
    21 android.view
     8 android.view.accessibility
     5 android.webkit
    13 android.widget
     2 bitter.jnibridge
   158 bolts
   399 com.facebook
  1856 com.facebook.android
   179 com.facebook.appevents
    76 com.facebook.appevents.internal
  1902 com.facebook.applinks
  1856 com.facebook.common
  1856 com.facebook.core
     9 com.facebook.devicerequests.internal
   607 com.facebook.internal
  2054 com.facebook.login
    81 com.facebook.login.widget
  1888 com.facebook.messenger
  1899 com.facebook.places
   109 com.facebook.places.internal
    70 com.facebook.places.model
  1907 com.facebook.share
   421 com.facebook.share.internal
   184 com.facebook.share.model
   130 com.facebook.share.widget
    52 com.facebook.unity
    25 com.google.ads
    23 com.google.ads.mediation
     1 com.google.ads.mediation.admob
    11 com.google.ads.mediation.customevent
  1850 com.google.android.gms
    20 com.google.android.gms.actions
  1850 com.google.android.gms.admob
  1850 com.google.android.gms.admob.impl.license
  1850 com.google.android.gms.admob.license
    54 com.google.android.gms.ads
    12 com.google.android.gms.ads.doubleclick
    48 com.google.android.gms.ads.formats
    16 com.google.android.gms.ads.identifier
  1850 com.google.android.gms.ads.impl
   315 com.google.android.gms.ads.internal
    68 com.google.android.gms.ads.internal.gmsg
    68 com.google.android.gms.ads.internal.js
    70 com.google.android.gms.ads.internal.overlay
    39 com.google.android.gms.ads.mediation
     1 com.google.android.gms.ads.mediation.admob
    12 com.google.android.gms.ads.mediation.customevent
     1 com.google.android.gms.ads.reward.mediation
    20 com.google.android.gms.ads.search
  1904 com.google.android.gms.auth
     5 com.google.android.gms.auth.account
  1873 com.google.android.gms.auth.api
    68 com.google.android.gms.auth.api.accounttransfer
    99 com.google.android.gms.auth.api.credentials
  1856 com.google.android.gms.auth.api.phone
  1850 com.google.android.gms.auth.api.phone.license
    37 com.google.android.gms.auth.api.proxy
    61 com.google.android.gms.auth.api.signin
    37 com.google.android.gms.auth.api.signin.internal
  1850 com.google.android.gms.auth.license
  1850 com.google.android.gms.base
  1850 com.google.android.gms.base.license
    49 com.google.android.gms.clearcut
   112 com.google.android.gms.common
    98 com.google.android.gms.common.api
   342 com.google.android.gms.common.api.internal
    41 com.google.android.gms.common.data
    44 com.google.android.gms.common.images
   160 com.google.android.gms.common.internal
  1850 com.google.android.gms.common.license
    35 com.google.android.gms.common.stats
    29 com.google.android.gms.common.util
  1998 com.google.android.gms.drive
    54 com.google.android.gms.drive.events
  1850 com.google.android.gms.drive.license
    10 com.google.android.gms.drive.metadata
    20 com.google.android.gms.drive.metadata.internal
    39 com.google.android.gms.drive.query
    49 com.google.android.gms.drive.query.internal
     8 com.google.android.gms.drive.widget
    25 com.google.android.gms.dynamic
    20 com.google.android.gms.dynamite
     2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.ads.dynamite
     2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
    16 com.google.android.gms.flags.impl
  2226 com.google.android.gms.games
    25 com.google.android.gms.games.achievement
    13 com.google.android.gms.games.event
   156 com.google.android.gms.games.internal
   128 com.google.android.gms.games.internal.api
    12 com.google.android.gms.games.internal.experience
    46 com.google.android.gms.games.internal.player
    61 com.google.android.gms.games.leaderboard
  1850 com.google.android.gms.games.license
    61 com.google.android.gms.games.multiplayer
    50 com.google.android.gms.games.multiplayer.realtime
    49 com.google.android.gms.games.multiplayer.turnbased
    56 com.google.android.gms.games.quest
    34 com.google.android.gms.games.request
    46 com.google.android.gms.games.snapshot
    15 com.google.android.gms.games.stats
    40 com.google.android.gms.games.video
  1850 com.google.android.gms.gass
  1850 com.google.android.gms.gass.license
  5449 com.google.android.gms.internal
     5 com.google.android.gms.location.places
  1857 com.google.android.gms.nearby
    82 com.google.android.gms.nearby.connection
  1850 com.google.android.gms.nearby.license
    95 com.google.android.gms.nearby.messages
     2 com.google.android.gms.nearby.messages.audio
   164 com.google.android.gms.nearby.messages.internal
    63 com.google.android.gms.phenotype
     6 com.google.android.gms.security
  1905 com.google.android.gms.tasks
  1850 com.google.android.gms.tasks.license
  1850 com.google.example.games.mainlibproj
  1891 com.google.games.bridge
     6 com.google.unity
  1936 com.google.unity.ads
     2 com.google.zxing
   222 com.unity3d.player
  1850 de.hydraware.------
    26 java.lang
    11 java.lang.annotation
     2 java.math
     2 java.nio
     1 java.nio.channels
     1 java.text
     6 java.util
     5 java.util.concurrent
     2 java.util.logging
     4 javax.microedition.khronos.egl
    20 org.fmod
     1 org.json
]
stdout[
processing archive /Users/----/Dropbox/-------/Unity Project/Unity_Project/------/Temp/StagingArea/android-libraries/GoogleMobileAdsPlugin/libs/./unity-plugin-library.jar...
processing com/google/unity/BuildConfig.class...
processing com/google/unity/ads/AdNetworkExtras.class...
processing com/google/unity/ads/Banner.class...
processing com/google/unity/ads/Banner$1.class...
processing com/google/unity/ads/Banner$10.class...
processing com/google/unity/ads/Banner$11.class...
processing com/google/unity/ads/Banner$12.class...
processing com/google/unity/ads/Banner$13.class...
processing com/google/unity/ads/Banner$2.class...
processing com/google/unity/ads/Banner$3.class...
processing com/google/unity/ads/Banner$4.class...
processing com/google/unity/ads/Banner$5.class...
processing com/google/unity/ads/Banner$6.class...
processing com/google/unity/ads/Banner$7.class...
processing com/google/unity/ads/Banner$8.class...
processing com/google/unity/ads/Banner$9.class...
processing com/google/unity/ads/CustomNativeAd.class...
processing com/google/unity/ads/CustomNativeAd$1.class...
processing com/google/unity/ads/CustomNativeAd$2.class...
processing com/google/unity/ads/Interstitial.class...
processing com/google/unity/ads/Interstitial$1.class...
processing com/google/unity/ads/Interstitial$1$1.class...
processing com/google/unity/ads/Interstitial$2.class...
processing com/google/unity/ads/Interstitial$3.class...
processing com/google/unity/ads/NativeAdLoader.class...
processing com/google/unity/ads/NativeAdLoader$1.class...
processing com/google/unity/ads/NativeAdLoader$2.class...
processing com/google/unity/ads/NativeAdLoader$3.class...
processing com/google/unity/ads/NativeAdLoader$3$1.class...
processing com/google/unity/ads/NativeAdLoader$3$2.class...
processing com/google/unity/ads/NativeAdLoader$3$3.class...
processing com/google/unity/ads/NativeAdLoader$4.class...
processing com/google/unity/ads/PluginUtils.class...
processing com/google/unity/ads/RewardBasedVideo.class...
processing com/google/unity/ads/RewardBasedVideo$1.class...
processing com/google/unity/ads/RewardBasedVideo$1$1.class...
processing com/google/unity/ads/RewardBasedVideo$2.class...
processing com/google/unity/ads/RewardBasedVideo$3.class...
processing com/google/unity/ads/RewardBasedVideo$4.class...
processing com/google/unity/ads/UnityAdListener.class...
processing com/google/unity/ads/UnityAdLoaderListener.class...
processing com/google/unity/ads/UnityRewardBasedVideoAdListener.class...
processing archive /Users/-------/Dropbox/-------/Unity Project/Unity_Project/-----/Temp/StagingArea/android-libraries/android.arch.lifecycle.runtime-1.0.0/libs/./classes.jar...
processing android/arch/lifecycle/BuildConfig.class...
processing android/arch/lifecycle/LifecycleRegistry.class...
processing android/arch/lifecycle/LifecycleRegistry$1.class...
processing android/arch/lifecycle/LifecycleRegistry$ObserverWithState.class...
processing android/arch/lifecycle/LifecycleRegistryOwner.class...
processing android/arch/lifecycle/ReportFragment.class...
processing android/arch/lifecycle/ReportFragment$ActivityInitializationListener.class...
processing archive /Users/-------/Dropbox/-------/Unity Project/Unity_Project/-------/Temp/StagingArea/android-libraries/com.android.support.animated-vector-drawable-26.1.0/libs/./classes.jar...
processing android/support/graphics/drawable/Animatable2Compat.class...
processing android/support/graphics/drawable/Animatable2Compat$AnimationCallback.class...
processing android/support/graphics/drawable/Animatable2Compat$AnimationCallback$1.class...
processing android/support/graphics/drawable/AnimatedVectorDrawableCompat.class...
processing android/support/graphics/drawable/AnimatedVectorDrawableCompat$1.class...
processing android/support/graphics/drawable/AnimatedVectorDrawableCompat$2.class...
processing android/support/graphics/drawable/AnimatedVectorDrawableCompat$AnimatedVectorDrawableCompatState.class...
processing android/support/graphics/drawable/AnimatedVectorDrawableCompat$AnimatedVectorDrawableDelegateState.class...
processing android/support/graphics/drawable/AnimationUtilsCompat.class...
processing android/support/graphics/drawable/AnimatorInflaterCompat.class...
processing android/support/graphics/drawable/AnimatorInflaterCompat$1.class...
processing android/support/graphics/drawable/AnimatorInflaterCompat$PathDataEvaluator.class...
processing android/support/graphics/drawable/ArgbEvaluator.class...
processing android/support/graphics/drawable/PathInterpolatorCompat.class...
processing android/support/graphics/drawable/animated/BuildConfig.class...
processing archive /Users/------/Dropbox/-----/Unity Project/Unity_Project/------/Temp/StagingArea/android-libraries/com.android.support.appcompat-v7-26.1.0/libs/./classes.jar...
processing android/support/v7/app/ActionBar.class...
processing android/support/v7/app/ActionBar$DisplayOptions.class...
processing android/support/v7/app/ActionBar$LayoutParams.class...
processing android/support/v7/app/ActionBar$NavigationMode.class...
processing android/support/v7/app/ActionBar$OnMenuVisibilityListener.class...
processing android/support/v7/app/ActionBar$OnNavigationListener.class...
processing android/support/v7/app/ActionBar$Tab.class...
processing android/support/v7/app/ActionBar$TabListener.class...
processing android/support/v7/app/ActionBarDrawerToggle.class...
processing android/support/v7/app/ActionBarDrawerToggle$1.class...
processing android/support/v7/app/ActionBarDrawerToggle$Delegate.class...
processing android/support/v7/app/ActionBarDrawerToggle$DelegateProvider.class...
processing android/support/v7/app/ActionBarDrawerToggle$DummyDelegate.class...
processing android/support/v7/app/ActionBarDrawerToggle$HoneycombDelegate.class...
processing android/support/v7/app/ActionBarDrawerToggle$IcsDelegate.class...
processing android/support/v7/app/ActionBarDrawerToggle$JellybeanMr2Delegate.class...
processing android/support/v7/app/ActionBarDrawerToggle$ToolbarCompatDelegate.class...
processing android/support/v7/app/ActionBarDrawerToggleHoneycomb.class...
processing android/support/v7/app/ActionBarDrawerToggleHoneycomb$SetIndicatorInfo.class...
processing android/support/v7/app/AlertController.class...
processing android/support/v7/app/AlertController$1.class...
processing android/support/v7/app/AlertController$2.class...
processing android/support/v7/app/AlertController$3.class...
processing android/support/v7/app/AlertController$4.class...
processing android/support/v7/app/AlertController$5.class...
processing android/support/v7/app/AlertController$AlertParams.class...
processing android/support/v7/app/AlertController$AlertParams$1.class...
processing android/support/v7/app/AlertController$AlertParams$2.class...
processing android/support/v7/app/AlertController$AlertParams$3.class...
processing android/support/v7/app/AlertController$AlertParams$4.class...
processing android/support/v7/app/AlertController$AlertParams$OnPrepareListViewListener.class...
processing android/support/v7/app/AlertController$ButtonHandler.class...
processing android/support/v7/app/AlertController$CheckedItemAdapter.class...
processing android/support/v7/app/AlertController$RecycleListView.class...
processing android/support/v7/app/AlertDialog.class...
processing android/support/v7/app/AlertDialog$Builder.class...
processing android/support/v7/app/AppCompatActivity.class...
processing android/support/v7/app/AppCompatCallback.class...
processing android/support/v7/app/AppCompatDelegate.class...
processing android/support/v7/app/AppCompatDelegate$ApplyableNightMode.class...
processing android/support/v7/app/AppCompatDelegate$NightMode.class...
processing android/support/v7/app/AppCompatDelegateImplBase.class...
processing android/support/v7/app/AppCompatDelegateImplBase$1.class...
processing android/support/v7/app/AppCompatDelegateImplBase$ActionBarDrawableToggleImpl.class...
processing android/support/v7/app/AppCompatDelegateImplBase$AppCompatWindowCallbackBase.class...
processing android/support/v7/app/AppCompatDelegateImplN.class...
processing android/support/v7/app/AppCompatDelegateImplN$AppCompatWindowCallbackN.class...
processing android/support/v7/app/AppCompatDelegateImplV11.class...
processing android/suppor<message truncated>