Java中的 Bidi createLineBidi() 方法及示例
Java.text.Bidi类的createLineBidi ()方法用于创建一个新的bidi 对象,该对象具有相同的基本方向并表示范围内当前bidi 的每个属性。
句法:
public Bidi createLineBidi(int lineStart,
int lineLimit)
参数:此方法将以下参数作为参数
- lineStart : 它是这个新的比迪酒的起点
- lineLimit : 这是这个新比迪酒的终点
返回值:此方法返回一个新的Bidi 对象
下面是说明createLineBidi()方法的示例:
示例 1:
// Java program to demonstrate
// createLineBidi() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing Bidi
// text with base direction
Bidi bidi
= new Bidi(
"Geeks For Geeks",
Bidi.DIRECTION_RIGHT_TO_LEFT);
// creating and new bidi Object using the old one
// using createLineBidi() method
Bidi newbidi = bidi.createLineBidi(1, 6);
// display the new bidi status
System.out.println("New Bidi "
+ "\nLength : "
+ newbidi.getLength()
+ "\nnumber of levels : "
+ newbidi.getRunCount()
+ "\nBase Level : "
+ newbidi.getBaseLevel());
}
}
输出:
New Bidi
Length : 5
number of levels : 2
Base Level : 1
示例 2:
// Java program to demonstrate
// createLineBidi() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing Bidi
// text with base direction
Bidi bidi
= new Bidi("Tajmahal",
Bidi.DIRECTION_RIGHT_TO_LEFT);
// creating and new bidi Object using the old one
// using createLineBidi() method
Bidi newbidi = bidi.createLineBidi(3, 5);
// display the new bidi status
System.out.println("New Bidi "
+ "\nLength : "
+ newbidi.getLength()
+ "\nnumber of levels : "
+ newbidi.getRunCount()
+ "\nBase Level : "
+ newbidi.getBaseLevel());
}
}
输出:
New Bidi
Length : 2
number of levels : 1
Base Level : 2
参考: https://docs.oracle.com/javase/9/docs/api/ Java/text/Bidi.html#createLineBidi-int-int-