Android Handler NullPointerException - android-listview

The Activity creates a new Thread.
The run() method gets an object (vector) via input stream.
Now I want to display the contents of this Vector on a ListView called direc.
That's all...but its not working and throws an Exception.
The code:
public class FileExplorerActivity extends Activity implements Runnable
{
public static final String TAG="ricky";
Vector<String> dirs = new Vector<String>();
ListView direc;
static ArrayAdapter<String> arrayAdapter;
Handler handler;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.fileexplorer);
direc = (ListView) findViewById(R.id.directoriesss);
handler = new Handler();
Thread thread = new Thread(this);
thread.start();
}
public FileExplorerActivity()
{
}
public void run()
{
Log.d(TAG, "FileExplorer: Thread started");
try
{
Log.d(TAG, "FileExplorer: reading data");
dirs = (Vector<String>) ConnectionThread.din.readObject();
Log.d(TAG, "FileExplorer: read data");
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.activity_list_item,
android.R.id.text2 , dirs);
Log.d(TAG, "FileExplorer: ArrayAdapter created");
handler.post( new Runnable() {
public void run()
{
Log.d(TAG, "FileExplorer: In handler Thread");
direc.setAdapter(arrayAdapter);
Log.d(TAG, "FileExplorer: Updated UI");
}
});
Log.d(TAG, "FileExplorer: Directory set");
}catch (Exception e) {
Log.d(TAG, "FileExplorerActivity: Exception:"+e.getMessage());
}
}
}
Here is what Logcat has to say:
> 1. 05-24 20:14:46.601 7759 7834 D ricky : FileExplorer: Thread started
> 2. 05-24 20:14:46.601 7759 7834 D ricky : FileExplorer: reading data
> 3. 05-24 20:14:46.648 7759 7834 D ricky : FileExplorer: read data
> 4. 05-24 20:14:46.648 7759 7834 D ricky : FileExplorer: ArrayAdapter created
> 5. 05-24 20:14:46.648 7759 7834 D ricky : FileExplorer: Directory set
> 6. 05-24 20:14:46.656 7759 7759 D ricky : FileExplorer: In handler Thread
> 7. 05-24 20:14:46.656 7759 7759 D ricky : FileExplorer: Updated UI
> 8. 05-24 20:14:46.664 7759 7759 D AndroidRuntime: Shutting down VM
> 9. 05-24 20:14:46.664 7759 7759 W dalvikvm: threadid=1: thread exiting with uncaught 10. exception (group=0x4001e560)
> 11. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: FATAL EXCEPTION: main
> 12. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: java.lang.NullPointerException
> 13. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:353)
> 14. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
> 15. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.AbsListView.obtainView(AbsListView.java:1456)
> 16. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.ListView.measureHeightOfChildren(ListView.java :1291)
> 17. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.ListView.onMeasure(ListView.java:1202)
> 18. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.View.measure(View.java:8355)
> 19. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java :3279)
> 20. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
> 21. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.LinearLayout.measureHorizontal(LinearLayout.ja va:701)
> 22. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
> 23. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.View.measure(View.java:8355)
> 24. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java :3279)
> 25. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
> 26. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.View.measure(View.java:8355)
> 27. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.LinearLayout.measureVertical(LinearLayout.java :531)
> 28. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
> 29. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.View.measure(View.java:8355)
> 30. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java :3279)
> 31. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
> 32. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.View.measure(View.java:8355)
> 33. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.ViewRoot.performTraversals(ViewRoot.java:882)
> 34. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.view.ViewRoot.handleMessage(ViewRoot.java:1917)
> 35. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
> 36. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.os.Looper.loop(Looper.java:130)
> 37. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:3859)
> 38. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
> 39. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:507)
> 40. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 41. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
> 42. 05-24 20:14:46.687 7759 7759 E AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)

Note the line at which the NullPointerException occurs:
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:353)
This is becauseandroid.R.layout.activity_list_item does not contain android.R.id.text2.
You can use android.R.id.text1 instead or replace the row layout with simple_list_item_2.
I would suggest creating your own row layout to avoid these situations in the first place.

Move this
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.activity_list_item,
android.R.id.text2 , dirs);
inside your run() method so that it runs on the UI thread. You shouldn't create an ArrayAdapter outside of the UI thread.

Related

expo run:ios - build fails - errors exist in generated swift files

I am following this guide:
https://www.mongodb.com/docs/realm/sdk/react-native/bootstrap-with-expo/
but when I get to the step that says to run expo run:ios it fails with the following errors:
› Skipping dev server
› Planning build
› Executing react-native Pods/FBReactNativeSpec » [CP-User] Generate Specs
❌ (node_modules/expo-modules-core/ios/Swift/Functions/AsyncFunctionComponent.swift:94:17)
92 | }
93 |
> 94 | let queue = queue ?? defaultQueue
| ^ variable used within its own initial value
95 |
96 | queue.async { [body, name] in
97 | let returnedValue: ReturnType?
❌ (node_modules/expo-modules-core/ios/Swift/Views/ConcreteViewProp.swift:42:52)
40 | }
41 | guard let value = try propType.cast(value) as? PropType else {
> 42 | throw Conversions.CastingException<PropType>(value)
| ^ variable declared in 'guard' condition is not usable in its body
43 | }
44 | setter(view, value)
45 | }
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:8:33)
6 | */
7 | public final class ConcurrentFunctionDefinition<Args, FirstArgType, ReturnType>: AnyFunction {
> 8 | typealias ClosureType = (Args) async throws -> ReturnType
| ^ consecutive declarations on a line must be separated by ';'
9 |
10 | let body: ClosureType
11 |
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:8:34)
6 | */
7 | public final class ConcurrentFunctionDefinition<Args, FirstArgType, ReturnType>: AnyFunction {
> 8 | typealias ClosureType = (Args) async throws -> ReturnType
| ^ expected declaration
9 |
10 | let body: ClosureType
11 |
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:56:36)
54 | // swiftlint:disable force_cast
55 | let argumentsTuple = try Conversions.toTuple(arguments) as! Args
> 56 | let returnValue = try await body(argumentsTuple)
| ^ consecutive statements on a line must be separated by ';'
57 |
58 | result = .success(returnValue)
59 | } catch let error as Exception {
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:94:49)
92 | public func AsyncFunction<R>(
93 | _ name: String,
> 94 | #_implicitSelfCapture _ closure: #escaping () async throws -> R
| ^ expected ',' separator
95 | ) -> ConcurrentFunctionDefinition<(), Void, R> {
96 | return ConcurrentFunctionDefinition(
97 | name,
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:94:62)
92 | public func AsyncFunction<R>(
93 | _ name: String,
> 94 | #_implicitSelfCapture _ closure: #escaping () async throws -> R
| ^ expected ':' following argument label and parameter name
95 | ) -> ConcurrentFunctionDefinition<(), Void, R> {
96 | return ConcurrentFunctionDefinition(
97 | name,
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:109:51)
107 | public func AsyncFunction<R, A0: AnyArgument>(
108 | _ name: String,
> 109 | #_implicitSelfCapture _ closure: #escaping (A0) async throws -> R
| ^ expected ',' separator
110 | ) -> ConcurrentFunctionDefinition<(A0), A0, R> {
111 | return ConcurrentFunctionDefinition(
112 | name,
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:109:64)
107 | public func AsyncFunction<R, A0: AnyArgument>(
108 | _ name: String,
> 109 | #_implicitSelfCapture _ closure: #escaping (A0) async throws -> R
| ^ expected ':' following argument label and parameter name
110 | ) -> ConcurrentFunctionDefinition<(A0), A0, R> {
111 | return ConcurrentFunctionDefinition(
112 | name,
❌ (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:124:55)
122 | public func AsyncFunction<R, A0: AnyArgument, A1: AnyArgument>(
123 | _ name: String,
> 124 | #_implicitSelfCapture _ closure: #escaping (A0, A1) async throws -> R
| ^ expected ',' separator
125 | ) -> ConcurrentFunctionDefinition<(A0, A1), A0, R> {
126 | return ConcurrentFunctionDefinition(
127 | name,
... Hundreds of similar errors later...
❌ (node_modules/expo-modules-core/ios/Swift/Views/ViewDefinition.swift:68:3)
66 | public func View<ViewType: UIView>(
67 | _ viewType: ViewType.Type,
> 68 | #ViewDefinition<ViewType>.ElementsBuilder _ elements: #escaping () -> [AnyDefinition]
| ^ struct 'ElementsBuilder' cannot be used as an attribute
69 | ) -> ViewDefinition<ViewType> {
70 | return ViewDefinition(viewType, elements: elements())
71 | }
❌ (node_modules/expo-modules-core/ios/Swift/Views/ViewManagerDefinitionComponents.swift:19:3)
17 | public func Prop<ViewType: UIView, PropType: AnyArgument>(
18 | _ name: String,
> 19 | #_implicitSelfCapture _ setter: #escaping (ViewType, PropType) -> Void
| ^ unknown attribute '_implicitSelfCapture'
20 | ) -> ConcreteViewProp<ViewType, PropType> {
21 | return ConcreteViewProp(
22 | name: name,
❌ (node_modules/expo-modules-core/ios/Swift/Views/ViewManagerDefinitionComponents.swift:34:3)
32 | */
33 | public func OnViewDidUpdateProps<ViewType: UIView>(
> 34 | #_implicitSelfCapture _ closure: #escaping (_ view: ViewType) -> Void
| ^ unknown attribute '_implicitSelfCapture'
35 | ) -> ViewLifecycleMethod<ViewType> {
36 | return ViewLifecycleMethod(type: .didUpdateProps, closure: closure)
37 | }
› Compiling react-native Pods/React-RCTVibration » RCTVibrationPlugins.mm
› Compiling react-native Pods/React-RCTVibration » RCTVibration.mm
› Compiling react-native Pods/React-RCTVibration » React-RCTVibration-dummy.m
› Compiling react-native Pods/React-RCTSettings » RCTSettingsManager.mm
› Compiling react-native Pods/React-RCTSettings » React-RCTSettings-dummy.m
› Compiling react-native Pods/React-RCTSettings » RCTSettingsPlugins.mm
› Compiling react-native Pods/React-RCTNetwork » React-RCTNetwork-dummy.m
› 104 error(s), and 0 warning(s)
I'm not sure what I'm doing wrong Xcode says the following statement
CommandError: Failed to build iOS project. "xcodebuild" exited with error code 65.
I have the latest expo cli installed
I tried building the project in Xcode directly, the project did build, but it won't launch on the emulator, expo opens but when connecting to the dev server the app just crashes.
I do not understand why running expo run:ios results in a build failure while building in Xcode results in a "success".
The solution is actually kind of silly,
so the reason I was able to build successfully in Xcode vs not build successfully using expo run:ios is because I have two version of Xcode installed on this machine. one version is Xcode 12.3, and xcrun was pointed to that sdk package. I was able to fix this by running sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer double checking xcrun --show-sdk-path should now list the appropriate pathing. for good measure I deleted the pods file and the pod.lock file and rebuilt the app using expo run:ios

Game crashes when loading Admob smart banner

I just upgrade my game to Unity 2019.2.0f1 and Admob 3.18.2
Now it crashes when I load smart banner (other adsize works fine).
Here is the log:
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean com.google.android.gms.ads.AdSize.equals(java.lang.Object)'
on a null object reference 08-03 14:57:29.307 19834 19834 E
AndroidRuntime: at
com.google.android.gms.internal.ads.zzwu.zza(com.google.android.gms:play-services-ads-lite##18.1.1:248)
08-03 14:57:29.307 19834 19834 E AndroidRuntime: at
com.google.android.gms.internal.ads.zzwu.zza(com.google.android.gms:play-services-ads-lite##18.1.1:87)
08-03 14:57:29.307 19834 19834 E AndroidRuntime: at
com.google.android.gms.ads.BaseAdView.loadAd(com.google.android.gms:play-services-ads-lite##18.1.1:15)
08-03 14:57:29.307 19834 19834 E AndroidRuntime: at
com.google.android.gms.ads.AdView.loadAd(com.google.android.gms:play-services-ads-lite##18.1.1:18)
08-03 14:57:29.307 19834 19834 E AndroidRuntime: at
com.google.unity.ads.Banner$5.run(Banner.java:278) 08-03 14:57:29.307
19834 19834 E AndroidRuntime: at
android.os.Handler.handleCallback(Handler.java:789) 08-03 14:57:29.307
19834 19834 E AndroidRuntime: at
android.os.Handler.dispatchMessage(Handler.java:98) 08-03 14:57:29.307
19834 19834 E AndroidRuntime: at
android.os.Looper.loop(Looper.java:164) 08-03 14:57:29.307 19834 19834
E AndroidRuntime: at
android.app.ActivityThread.main(ActivityThread.java:6944) 08-03
14:57:29.307 19834 19834 E AndroidRuntime: at
java.lang.reflect.Method.invoke(Native Method) 08-03 14:57:29.307
19834 19834 E AndroidRuntime: at
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
08-03 14:57:29.307 19834 19834 E AndroidRuntime: at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Here is the code:
m_BannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
m_BannerView.OnAdLoaded += HandleOnAdLoaded;
m_BannerView.OnAdFailedToLoad += HandleOnAdFailedToLoad;
m_BannerView.OnAdOpening += HandleOnAdOpened;
m_BannerView.OnAdClosed += HandleOnAdClosed;
m_BannerView.OnAdLeavingApplication += HandleOnAdLeavingApplication;
AdRequest request = new AdRequest.Builder().Build();
m_BannerView.LoadAd(request);
There's a thread on googleads-mobile-unity github about this issue:
https://github.com/googleads/googleads-mobile-unity/issues/987
One of contributors replied:
I recommend using Unity version 2019.1.11f1 until we determine the cause of
this. We believe it could be a Unity issue, as the Smart banner reference
is null even when proguard is off.
The solution of luvjungle and more specifically the comment of Juan Bentel worked like a charm for me
"Another one posted a working fix! GetAdSizeJavaObject inside Assets/GoogleMobileAds/Platforms/Android/Utils.cs seems to be broken. The first return must be changed to: return new AndroidJavaObject(AdSizeClassName, adSize.Width, adSize.Height).GetStatic("SMART_BANNER"); – Juan Bentel Aug 11 at 8:03 "

Elixir UUID. How to handle 500 error when UUID doesn't match

def show(conn, %{"id" => id}) do
with {:ok, user} <- UserAction.get_user(id)
|> put_status(200)
|> render("show.json", %{user: user})
else
{:error, :not_found} -> {:error, :not_found, %User{id: id}}
end
end
When id is invalid, Ecto raises:
Ecto.Query.CastError - cannot be dumped to type :binary_id in query.
My get_user function:
query = from(u in User, where u.id == ^id)
case Repo.all(query) do
[%User{} = user] -> {:ok, user}
_ -> {:error, :not_found}
end
Is there any convenient way for handling this error to prevent 500 responses?
That's a known issue with UUID, Binary and other ecto types that need to conform to a specific standard (It's a feature, not a bug™️). Like #TheAnh mentioned, you can use Ecto.UUID.dump/1 to check if the id is valid, but I prefer straight-up rescuing it:
def get_user(id) do
Repo.get(User, id)
rescue
Ecto.Query.CastError -> nil
end
Override Repo
The above example can get tedious because you'll have to rescue everywhere you call get. So I override the get/3 function in MyApp.Repo:
# lib/my_app/repo.ex
defoverridable [get: 2, get: 3]
def get(query, id, opts \\ []) do
super(query, id, opts)
rescue
Ecto.Query.CastError -> nil
end
Use fetch for Tuple format
You should use fetch_* method names instead of get_* to return values in tuple format (to avoid confusion with default Repo methods):
# lib/my_app/repo.ex
def fetch(query, id, opts \\ []) do
case get(query, id, opts) do
nil -> {:error, :not_found}
schema -> {:ok, schema}
end
end
And call it like this in your main function:
def fetch_user(id) do
Repo.fetch(User, id)
end
I've ended up with guard macros
defmacro is_uuid(value) do
quote do
is_binary(unquote(value)) and byte_size(unquote(value)) == 36 and
binary_part(unquote(value), 8, 1) == "-" and binary_part(unquote(value), 13, 1) == "-" and
binary_part(unquote(value), 18, 1) == "-" and binary_part(unquote(value), 23, 1) == "-"
end
end
Usage:
def get_user(id) when is_uuid(id) do
Repo.get(User, id)
end
def get_user(_id), do: {:error, :not_found}
To return 400 you need to update the conn with the appropriate status and then render.
conn
|> put_status(:not_found)
|> put_view(YourApp.ErrorView)
|> render("404.html")
This would be carried out in the else clause of your with expression. You can take this idea further with custom errors: https://hexdocs.pm/phoenix/errors.html
I would advise to check if the input is invalid before operating on it if possible.
There are a few ways you. could validate prior to trying to execute a db query. One solid way is try and cast the value before attempting the query.
iex(1)> Ecto.UUID.cast("no good")
:error
iex(2)> Ecto.UUID.cast("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
:error
iex(3)> Ecto.UUID.cast("de851708-7f7a-40e1-b8ec-da2baec30839")
{:ok, "de851708-7f7a-40e1-b8ec-da2baec30839"}
Given the above behavior above you can wrap your with expression in a case expression. Though, I'm not sure I would use with here either, it's better for pipelines.
case Ecto.UUID.cast(id) do
:error ->
conn |> put_status(400) |> render("error.json", %{message: "Some Message"})
{:ok, uuid} ->
case UserAction.get_user(uuid) do
{:ok, user} ->
conn |> put_status(200) |> render("show.json", %{user: user})
_ ->
conn |> put_status(404) |> render("error.json", %{message: "User not found"})
end
end
Thanks to #vlad-horbachevsky answer, I extended it to my version of guard function:
defguard is_uuid(value)
when is_binary(value) and byte_size(value) == 36 and
binary_part(value, 1, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 2, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 3, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 4, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 5, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 6, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 7, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 8, 1) == "-" and
binary_part(value, 9, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 10, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 11, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 12, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 13, 1) == "-" and
binary_part(value, 14, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 15, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 16, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 17, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 18, 1) == "-" and
binary_part(value, 19, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 20, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 21, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 22, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 23, 1) == "-" and
binary_part(value, 24, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 25, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 26, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 27, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 28, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 29, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 30, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 31, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 32, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 33, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 34, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and
binary_part(value, 35, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F|
```

No output when running spark NetworkWordCount example

I am a Beginner of spark, and I am trying to use docker to run spark example NetworkWordCount. But no output when I run the example:
start a new terminal by docker exec -it container_id bash,
root#sandbox:/usr/local/spark# nc -lk 9999
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
a ba c d e f g
then start another terminal:
root#sandbox:/usr/local/spark# bin/run-example streaming.NetworkWordCount localhost 9999
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
16/05/12 02:55:57 INFO StreamingExamples: Setting log level to [WARN] for streaming example. To override add a custom log4j.properties to the classpath.
16/05/12 02:55:58 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
...
Anyone can help me?
Executing using below command worked for me.
[root#quickstart spark]# ./bin/run-example streaming.NetworkWordCount localhost 9999 --master "local[2]"

Additional space added while reading text from Notepad using powershell

My requirement is to find the location of a particular string in a line from notepad file but while reading it in powershell additional space get added that's why not able to find the location of a particular string. How I can find the location is this case??
I am using this code for achieving this
$ParamsPathForData = ($dir + "\TimeStats\TimeStats_1slot\29_12_2015_07TimeStats1.txt")
$data = Get-Content $ParamsPathForData
write-host $data.count total lines read from file
foreach ($line in $data)
{
$l =$line.IndexOf("12/29/2015")
write-host $l
}
I am reading this line from notepad ->
TimeStats 29 12/29/2015 7:13:42 AM +00:00 Debug PREPROCESS: SlotNo:
325-00313, Ip Address: 10.2.200.15, Duplicate Message: False,
Player-Card-No: , MessageId: 883250003130047966, MessageName:
GameIdInfo, Thread Init Delay: 14, Time To Parse: 155, Time To Exec
Main Workflow: 424, Time To Construct & send Response: 22, Total
Response Time: 615
But while exceuting it in powershell i am getting this with additinal spaces ->
T i m e S t a t s 2 9 1 2 / 2 9 / 2 0 1 5 7 : 1 3 : 4 2 A M
+ 0 0 : 0 0 D e b u g P R E P R O C E S S : S l o t N o : 3 2 5 - 0 0 3 1 3 , I p A d d r e s s : 1 0 . 2 . 2 0 0 . 1 5 , D
u p l i c a t e M e s s a g e : F a l s e , P l a y e r
- C a r d - N o : , M e s s a g e I d : 8 8 3 2 5 0 0 0 3 1 3 0 0 4 7 9 6 6 , M e s s a g e N a m e : G a m e I d I n f o , T h
r e a d I n i t D e l a y : 1 4 , T i m e T o P a r s e :
1 5 5 , T i m e T o E x e c M a i n W o r k f l o w : 4 2
4 , T i m e T o C o n s t r u c t & s e n d R e s p o n s
e : 2 2 , T o t a l R e s p o n s e T i m e : 6 1 5
Anybody please help me???
Change the the encoding to Unicode...
$data = Get-Content $ParamsPathForData -Encoding Unicode