Query a Key Having Space in Its Name with MongoDB

George John
Updated on 30-Jul-2019 22:30:25

2K+ Views

To query a key having space in its name, you can use dot(.) notation.Step 1: First, you need to create a set in which a key has space in its name. Following is the query:> myValues["Details"] = {} { } > myValues["Details"]["Student Name"]="John"; John > myValues["Details"]["StudentAge"]=26; 26Step 2: Now you need to create a collection and store the above set as a document. Following is the query> db.keyHavingSpaceDemo.insertOne( myValues); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca27e3b6304881c5ce84ba4") }Following is the query to display all documents from a collection with the help of find() method> db.keyHavingSpaceDemo.find().pretty();This will produce the following ... Read More

Check if Given Date Represents Weekend in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

2K+ Views

At first, display the current date:LocalDate date = LocalDate.now();Now, get the day of week from the above Date (current date):DayOfWeek day = DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK));On the basis of the above result, use SWITCH to check for the current day. If the day is SATURDAY/SUNDAY, then it’s Weekend.Exampleimport java.time.DayOfWeek; import java.time.temporal.ChronoField; import java.time.LocalDate; public class Demo {    public static void main(String[] argv) {       LocalDate date = LocalDate.now();       DayOfWeek day = DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK));       switch (day) {          case SATURDAY:             System.out.println("Weekend - Saturday");         ... Read More

IntBuffer wrap Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

377 Views

An int array can be wrapped into a buffer using the method wrap() in the class java.nio.IntBuffer. This method requires a single parameter i.e. the array to be wrapped into a buffer and it returns the new buffer created. If the returned buffer is modified, then the contents of the array are also similarly modified and vice versa.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       try {          int[] arr = { 8, 1, 3, 7, 5 ... Read More

KeyPairGenerator generateKeyPair Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

179 Views

A key pair can be generated using the generateKeyPair() method in the class java.security.KeyPairGenerator. This method requires no parameters and it returns the key pair that is generated. Every time the generateKeyPair() method is called, it generates a new key pair.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("RSA");          KeyPair keyPair = kpGenerator.generateKeyPair();          System.out.println(keyPair);       } catch (NoSuchAlgorithmException e) ... Read More

Use LIKE Clause in Android SQLite

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

277 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use LIKE Cause in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

Convert Between Binary and ASCII Using Python binascii

Smita Kapse
Updated on 30-Jul-2019 22:30:25

1K+ Views

The binascii module enables conversion between binary and various ASCII encoded binary representations. The binascii module contains low-level functions written in C for greater speed. They are used by the higher-level modules such as uu, base64 or binhex modules.The binascii module defines the following functions. These function are named as a2b_* or b2a_*binascii.a2b_uu(string): Convert a single line of uuencoded data back to binary and return the binary data. Lines normally contain 45 (binary) bytes, except for the last line. Line data may be followed by white space.binascii.b2a_uu(data): Convert binary data to a line of ASCII characters, the return value is the converted ... Read More

Get Android Device Fingerprint Information Programmatically

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

2K+ Views

This example demonstrate about How to get programmatically android device finger print information.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken text view to show device finger print information.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.app.ProgressDialog; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.webkit.CookieManager; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import ... Read More

Disable Action Bar Title in Android

Nitya Raut
Updated on 30-Jul-2019 22:30:25

278 Views

This example demonstrates How to disable action bar tittle in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity ... Read More

LongStream Filter Method in Java

George John
Updated on 30-Jul-2019 22:30:25

167 Views

The filter() method in the LongStream class in Java returns a stream consisting of the elements of this stream that match the given predicate.The syntax is as followsLongStream filter(LongPredicate predicate)Here, the parameter predicate is a stateless predicate to apply to each element to determine if it should be included. The LongPredicate represents a predicate (boolean-valued function) of one long-valued argumentTo use the LongStream class in Java, import the following packageimport java.util.stream.LongStream;The following is an example to implement LongStream filter() method in JavaExample Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) { LongStream longStream = ... Read More

Iterator Method of Java AbstractCollection Class

Smita Kapse
Updated on 30-Jul-2019 22:30:25

148 Views

The iterator() method of the AbstractCollection class in Java is used to return an iterator over the elements contained in this collection.The syntax is as follows −public abstract Iterator iterator()To work with AbstractCollection class in Java, import the following package −import java.util.AbstractCollection;For Iterator, import the following package −import java.util.Iterator;The following is an example to implement the AbstractCollection iterator() method in Java −Example Live Demoimport java.util.Iterator; import java.util.ArrayList; import java.util.AbstractCollection; public class Demo {    public static void main(String[] args) {       AbstractCollection absCollection = new ArrayList();       absCollection.add("Laptop");       absCollection.add("Tablet");       absCollection.add("Mobile"); ... Read More

Advertisements