本文整理汇总了Java中java.util.Scanner.findInLine方法的典型用法代码示例。如果您正苦于以下问题:Java Scanner.findInLine方法的具体用法?Java Scanner.findInLine怎么用?Java Scanner.findInLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Scanner
的用法示例。
在下文中一共展示了Scanner.findInLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setWinCeVersion
import java.util.Scanner; //导入方法依赖的package包/类
private void setWinCeVersion(OperatingSystem model) {
//TODO: to be refined
String osV = model.getVersion();
if (osV == null) {
return;
} else if (!model.getMajorRevision().equals("1")) {
return;
}
if (osV.matches(".*(\\d+).(\\d+).(\\d+).(\\d+).*")) {
Scanner s = new Scanner(osV);
s.findInLine(".*(\\d+).(\\d+).(\\d+).(\\d+).*");
MatchResult result = s.match();
if (result.group(1).equals("4")) {
model.setMajorRevision("5");
} else if (result.group(1).equals("6")) {
model.setMajorRevision("6");
if (result.group(3).equals("7")) {
model.setMinorRevision("1");
}
}
}
}
示例2: createTimeIntervalFromString
import java.util.Scanner; //导入方法依赖的package包/类
/**
* @generated NOT
*/
@Override
public TimeInterval createTimeIntervalFromString(final String value) {
final TimeIntervalImpl anInterval = new TimeIntervalImpl();
final Scanner scan = new Scanner(value);
final String leftPar = scan.findInLine("\\]|\\[");
anInterval.setMinOpen("]".equals(leftPar));
final String leftStr = scan.findInLine("[^,]*");
anInterval.setMin(createDurationFromString(leftStr));
scan.findInLine(",");
String rightStr = scan.findInLine("[^\\]\\[]*");
if (rightStr == null) {
rightStr = leftStr;
}
anInterval.setMax(createDurationFromString(rightStr));
final String rightPar = scan.findInLine("\\]|\\[");
anInterval.setMaxOpen("[".equals(rightPar));
scan.close();
return anInterval;
}
示例3: parseThreadInfo
import java.util.Scanner; //导入方法依赖的package包/类
protected ThreadStack parseThreadInfo(String threadInfo) {
Scanner s = new Scanner(threadInfo);
ThreadStack result = new ThreadStack();
// parsing thread info
s.findInLine(threadInfoPattern());
MatchResult res = s.match();
result.setThreadName(res.group(1));
result.setType(res.group(3));
result.setPriority(res.group(4));
result.setTid(res.group(7));
result.setNid(res.group(8));
result.setStatus(res.group(9));
s.close();
return result;
}
示例4: parseMethodInfo
import java.util.Scanner; //导入方法依赖的package包/类
protected MethodInfo parseMethodInfo(String line) {
MethodInfo result = new MethodInfo();
Scanner s = new Scanner(line);
s.findInLine(methodInfoPattern());
MatchResult rexp = s.match();
if (rexp.group(4) != null && rexp.group(4).length() > 0) {
// line " at tmtools.jstack.share.utils.Utils.sleep(Utils.java:29)"
result.setName(rexp.group(1));
result.setCompilationUnit(rexp.group(2));
result.setLine(rexp.group(4));
} else {
// line " at java.lang.Thread.sleep(Native Method)"
result.setName(rexp.group(1));
}
s.close();
return result;
}
示例5: scan
import java.util.Scanner; //导入方法依赖的package包/类
private static void scan(String input) {
Scanner s = new Scanner(input);
while (s.hasNextLine()) {
s.findInLine("5");
System.out.println(s.nextLine());
}
s.close();
}
示例6: ping
import java.util.Scanner; //导入方法依赖的package包/类
private Ping ping() throws IOException
{
log(String.format(Locale.US, "thread %d: ping test", threadId));
final long pingTimeNs = System.nanoTime();
String line = reader.readLine();
if (!line.startsWith("ACCEPT "))
{
log(String.format(Locale.US, "thread %d: got '%s' expected 'ACCEPT'", threadId, line));
return null;
}
final byte[] data = "PING\n".getBytes("US-ASCII");
final long timeStart = System.nanoTime();
out.write(data);
out.flush();
line = reader.readLine();
final long timeEnd = System.nanoTime();
out.write("OK\n".getBytes("US-ASCII"));
out.flush();
if (!line.equals("PONG"))
return null;
line = reader.readLine();
final Scanner s = new Scanner(line);
s.findInLine("TIME (\\d+)");
s.close();
final long diffClient = timeEnd - timeStart;
final long diffServer = Long.parseLong(s.match().group(1));
final double pingClient = diffClient / 1e6;
final double pingServer = diffServer / 1e6;
log(String.format(Locale.US, "thread %d - client: %.3f ms ping", threadId, pingClient));
log(String.format(Locale.US, "thread %d - server: %.3f ms ping", threadId, pingServer));
return new Ping(diffClient, diffServer, pingTimeNs);
}
示例7: setProxy
import java.util.Scanner; //导入方法依赖的package包/类
/**
* Define the proxy to use for all GA tracking requests.
* <p>
* Call this static method early (before creating any tracking requests).
*
* @param proxyAddr
* "addr:port" of the proxy to use; may also be given as URL
* ("http://addr:port/").
*/
public static void setProxy(String proxyAddr)
{
if(proxyAddr != null)
{
Scanner s = new Scanner(proxyAddr);
// Split into "proxyAddr:proxyPort".
proxyAddr = null;
int proxyPort = 8080;
try
{
s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
MatchResult m = s.match();
if(m.groupCount() >= 2)
proxyAddr = m.group(2);
if(m.groupCount() >= 4 && !(m.group(4).length() == 0))
proxyPort = Integer.parseInt(m.group(4));
}finally
{
s.close();
}
if(proxyAddr != null)
{
SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
setProxy(new Proxy(Type.HTTP, sa));
}
}
}
示例8: getVersionString
import java.util.Scanner; //导入方法依赖的package包/类
/**
* Gets the OS version string from a Linux release-specific file.
*/
private String getVersionString(File f){
try {
Scanner sc = new Scanner(f);
return sc.findInLine("(\\d)+((\\.)(\\d)+)*");
}
catch (Exception e){
}
return null;
}
示例9: expandProperties
import java.util.Scanner; //导入方法依赖的package包/类
private String expandProperties(final String input) {
String output = input;
Scanner s = new Scanner(output);
String foundInLine = null;
while ((foundInLine = s.findInLine("(\\$[\\{]\\w+[\\}])")) != null) {
String envProperty = getEnvProperty(extractKey(foundInLine));
envProperty = envProperty != null ? envProperty : "";
output = output.replace(foundInLine, envProperty);
}
return output;
}
示例10: createDurationFromString
import java.util.Scanner; //导入方法依赖的package包/类
/**
* @generated NOT
*/
@Override
public Duration createDurationFromString(final String value) {
if (value == null) {
return LongDurationImpl.ZERO;
}
final Scanner scan = new Scanner(value);
final String valueStr = scan.findInLine("\\d+(\\.\\d+)?");
String unitStr;
try {
unitStr = scan.next();// scan.next("\\w+");
} catch (NoSuchElementException e) {
// There is no units. Use default
unitStr = "ms";
}
scan.close();
final DurationImpl duration;
TimeUnitKind u = TimeUnitKind.getByName(unitStr);
if (u == null) {
u = TimeUnitKind.get(unitStr);
}
if (valueStr == null) {
duration = LongDurationImpl.ZERO;
} else {
duration = new LongDurationImpl(Double.parseDouble(valueStr), u);
}
return duration;
}
示例11: parseMonitorInfo
import java.util.Scanner; //导入方法依赖的package包/类
private MonitorInfo parseMonitorInfo(String line, String pattern) {
Scanner s = new Scanner(line);
s.findInLine(pattern);
MonitorInfo mi = new MonitorInfo();
MatchResult res = s.match();
mi.setType(res.group(1));
mi.setMonitorAddress(res.group(2));
if (res.groupCount() > 2) {
mi.setMonitorClass(res.group(3));
}
return mi;
}
示例12: parseExtendedStatus
import java.util.Scanner; //导入方法依赖的package包/类
protected String parseExtendedStatus(String line) {
Scanner s = new Scanner(line);
s.findInLine(extendedStatusPattern());
String result = s.match().group(1);
s.close();
return result;
}
示例13: parseJNIGlobalRefs
import java.util.Scanner; //导入方法依赖的package包/类
protected String parseJNIGlobalRefs(String line) {
Scanner s = new Scanner(line);
s.findInLine(jniGlobalRefInfoPattern());
String result = s.match().group(1);
s.close();
return result;
}
示例14: parseLockInfo
import java.util.Scanner; //导入方法依赖的package包/类
protected LockInfo parseLockInfo(String line) {
LockInfo res = new LockInfo();
Scanner s = new Scanner(line);
s.findInLine(ownableSynchronizersPattern());
MatchResult matchRes = s.match();
String lock = matchRes.group(1).equals("None") ? matchRes.group(1) : matchRes.group(2);
res.setLock(lock);
return res;
}
示例15: parseMenuLineText
import java.util.Scanner; //导入方法依赖的package包/类
/**
* Parses menu line like IDE Log L ============================ Toolbars > T
* [x] Show Editor Toolbar h [ ] Show Line Numbers S (x) Show Diff Sidebar D
*
* @param lineText
* @return parsed menu item from line
*/
public static NbMenuItem parseMenuLineText(String lineText) {
//parse line
Scanner line = new Scanner(lineText);
NbMenuItem menuitem = new NbMenuItem();
if (debug) {
System.out.println("Parsing line: " + line);
}
//is it separator? "======="
if (line.hasNext("^={5,}+\\s*")) { //at least 5x =
menuitem.setSeparator(true);
} else {
//does the line start with ( ?
String isRadio = line.findInLine("\\(.\\)");
if (isRadio != null) {
//System.out.println("parsing radiobutton: " + isRadio);
menuitem.setRadiobutton(true);
menuitem.setChecked(isRadio.indexOf("o") != -1);
} else {
//does the line start with [ ?
String isCheck = line.findInLine("\\[.\\]");
if (isCheck != null) {
//System.out.println("parsing checkbox: " + isCheck);
menuitem.setCheckbox(true);
menuitem.setChecked(isCheck.indexOf("x") != -1);
}
}
//read menu item text
StringBuffer text = new StringBuffer();
boolean read = true;
while (read && line.hasNext()) {
String partOfText = line.next();
if (partOfText.length() == 1 && partOfText.charAt(0) != '/') {
if (partOfText.charAt(0) == '>') {
menuitem.setSubmenu(new ArrayList<NbMenuItem>());
} else if (partOfText.charAt(0) == '-') {
// There is following project name, which has to be
// loaded right now. It is dynamicly changing.
partOfText = partOfText + " " + projectName;
text.append(partOfText);
text.append(" ");
} else {
//it must be the mnemonic
menuitem.setMnemo(partOfText.charAt(0));
read = false;
}
} else {
text.append(partOfText);
text.append(" ");
}
}
menuitem.setName(text.substring(0, text.length() - 1)); //remove the last " "
}
return menuitem;
}