Bidi isRightToLeft() method in Java with Examples
Last Updated :
18 Jan, 2022
The isRightToLeft() method of java.text.Bidi class is used to check if it has right to left line and base direction both or not.
Syntax:
public boolean isRightToLeft()
Parameter: This method accepts nothing as parameter.
Return Value: This method return true if this bidi has both right to left line and base direction otherwise false.
Below are the examples to illustrate the isRightToLeft() method:
Example 1:
Java
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
Bidi bidi
= new Bidi(
"Geeks For Geeks",
Bidi.DIRECTION_LEFT_TO_RIGHT);
boolean status = bidi.isRightToLeft();
if (status)
System.out.println(
"Both Line and Base "
+ "direction is right to left");
else
System.out.println(
"Both Line and Base "
+ "direction is not right to left");
}
}
|
Output:
Both Line and Base direction is not right to left
Example 2:
Java
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
AttributedString attr
= new AttributedString("GEEkS");
attr.addAttribute(
AttributedCharacterIterator
.Attribute
.LANGUAGE,
new Locale("ar_QA"));
Bidi bidi = new Bidi(attr.getIterator());
boolean status = bidi.isRightToLeft();
if (status)
System.out.println(
"Both Line and Base "
+ "direction is right to left");
else
System.out.println(
"Both Line and Base "
+ "direction is not right to left");
}
}
|
Output:
Both Line and Base direction is not right to left
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#isRightToLeft–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...