当前位置: 首页>>代码示例>>Java>>正文


Java Scanner.findInLine方法代码示例

本文整理汇总了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");
            }
        }
    }
}
 
开发者ID:OpenDDRmobi,项目名称:openddr-java,代码行数:27,代码来源:WinCEMozillaSubBuilder.java

示例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;
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:23,代码来源:NfpFactoryImpl.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:DefaultFormat.java

示例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;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DefaultFormat.java

示例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();
}
 
开发者ID:MinesJTK,项目名称:jtk,代码行数:9,代码来源:ScannerBug.java

示例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);
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:40,代码来源:RMBTTest.java

示例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));
		}
	}
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:41,代码来源:JGoogleAnalyticsTracker.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:MFontConfiguration.java

示例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;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:Gfsh.java

示例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;
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:32,代码来源:NfpFactoryImpl.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:DefaultFormat.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:DefaultFormat.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:DefaultFormat.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:DefaultFormat.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:Utilities.java


注:本文中的java.util.Scanner.findInLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。