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


Java Scanner.hasNextLine方法代码示例

本文整理汇总了Java中java.util.Scanner.hasNextLine方法的典型用法代码示例。如果您正苦于以下问题:Java Scanner.hasNextLine方法的具体用法?Java Scanner.hasNextLine怎么用?Java Scanner.hasNextLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Scanner的用法示例。


在下文中一共展示了Scanner.hasNextLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import java.util.Scanner; //导入方法依赖的package包/类
private static void load(Language language, String string) throws Exception {
  Scanner scanner = new Scanner(string);
  while (scanner.hasNextLine()) {
    String line = scanner.nextLine();
    if (line.startsWith("#")) continue;
    int index = line.indexOf("=");
    if (index == -1) continue;
    String str = line.substring(0, index).toLowerCase();
    String localization = line.substring(index + 1);
    language.add(str, localization);
  }
  scanner.close();
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:14,代码来源:Localization.java

示例2: registerAllIPCams

import java.util.Scanner; //导入方法依赖的package包/类
public static void registerAllIPCams(String fname)
{
	File f = new File(fname);
	if(f.exists()&&f.isFile())
	{
		try {
			Scanner scan = new Scanner(f);
			while(scan.hasNextLine())
			{
				registerIPCam(scan.nextLine());
			}
			scan.close();
		} catch (FileNotFoundException e) {
		}
	}
}
 
开发者ID:ForOhForError,项目名称:MTG-Card-Recognizer,代码行数:17,代码来源:WebcamUtils.java

示例3: init

import java.util.Scanner; //导入方法依赖的package包/类
public static void init() throws FileNotFoundException, IOException {

        Scanner scanner = new Scanner(file);
        scanner.nextLine(); //Skip the first (Title) line

        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (line.equals("*") || line.split(",").length < 3) { //To prevent reading the same line twice AND prevent reading a corrupted line
                break;
            }
            scores.put(Integer.parseInt(line.split(",")[1]), line.split(",")[0]); //Only looks at the first two columns (name and highscore)
        }

        sortScores();
        //printScores();
    }
 
开发者ID:ofrank123,项目名称:TheIntellectualOctocats,代码行数:17,代码来源:HighScore.java

示例4: processFile

import java.util.Scanner; //导入方法依赖的package包/类
/**   */
public Map processFile() throws FileNotFoundException {
    //FileReader is used, not File, since File is not Closeable
    scanner = new Scanner(new FileReader(file));
    try {
        //Scanner to get each line
        while (scanner.hasNextLine()) {
            processLine(scanner.nextLine());
        }
    } finally {
        //Close the underlying stream
        scanner.close();
    }
    return map;
}
 
开发者ID:phweda,项目名称:MFM,代码行数:16,代码来源:ParseTextFile.java

示例5: isVnrMapped

import java.util.Scanner; //导入方法依赖的package包/类
/**
 * Function that indicates if the virtual link mapping could be performed
 * 
 * @return boolean value indicating if the virtual link mapping could be
 *         performed
 * @throws FileNotFoundException
 */
@SuppressWarnings("static-access")
public boolean isVnrMapped() throws FileNotFoundException {
	
	try{
		  Thread.currentThread().sleep(500);
		}catch(InterruptedException ie){
		//If this thread was interrupted by another thread 
		}
	String filePath = MATLAB_PATH + MAPPING_PERFORMED + virtualNetReqNumber;
	fFile = new File(filePath);
	Scanner scanner = new Scanner(fFile);
	String[] decision;
	while (scanner.hasNextLine()) {

		decision = scanner.nextLine().split("   ");
		if (((int) (Double.parseDouble(decision[1]))) == 1) {
			return true;
		} else {
			return false;
		}
	}
	scanner.close();
	return false;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:32,代码来源:ReadResultMatlabFiles.java

示例6: getTemplateFileContent

import java.util.Scanner; //导入方法依赖的package包/类
/**
 * Read template with given template name
 *
 * @param template
 * @return template string
 */
private String getTemplateFileContent(String template) {
    StringBuilder builder = new StringBuilder();
    InputStream in = getClass().getResourceAsStream(template);
    Scanner scanner = new Scanner(in);
    while (scanner.hasNextLine()) {
        builder.append(scanner.nextLine());
    }
    return builder.toString();

}
 
开发者ID:GSLabDev,项目名称:pepper-box,代码行数:17,代码来源:SchemaTranslator.java

示例7: getPartitionsLinesByType

import java.util.Scanner; //导入方法依赖的package包/类
public static HashMap<String, Integer> getPartitionsLinesByType(IDocument document,
    String partitionType) {
  HashMap<String, Integer> lines = new HashMap<String, Integer>();
  final Scanner scanner = new Scanner(document.get());
  int lineNumber = 0;
  try {
    while (scanner.hasNextLine()) {
      final String line = scanner.nextLine();
      final int offset = document.getLineOffset(lineNumber);
      if (document.getPartition(offset).getType().equals(partitionType)) {
        lines.put(line, lineNumber);
      }
      lineNumber++;
    }
  } catch (BadLocationException e) {
    e.printStackTrace();
  } finally {
    if (scanner != null)
      scanner.close();
  }

  return lines;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:EditorUtilities.java

示例8: loadObstaclesFromPoses

import java.util.Scanner; //导入方法依赖的package包/类
public void loadObstaclesFromPoses() {
	try {
		Scanner in = new Scanner(new FileReader(posesFileName));
		while (in.hasNextLine()) {
			String line = in.nextLine().trim();
			if (line.length() != 0 && !line.startsWith("#")) {
				String[] oneline = line.split(" |\t");
				if (oneline.length == 4) {
					Pose ps = null;
					String obsName = oneline[0];
					obstacleNames.add(obsName);
					ps = new Pose(
							new Double(oneline[1]).doubleValue(),
							new Double(oneline[2]).doubleValue(),
							new Double(oneline[3]).doubleValue());
					Geometry obs = makeObstacle(ps);
					int id = obstacles.size()-1;
					panel.addGeometry("obs_"+id, obs, false, false, true, "#cc3300");
					selectedObsInt.add(id);
				}
			}
		}
		in.close();
		clearPathPointSelection();
		highlightObstacles();
	}
	catch (FileNotFoundException e) { e.printStackTrace(); }
}
 
开发者ID:FedericoPecora,项目名称:coordination_oru,代码行数:29,代码来源:PathEditor.java

示例9: parseSubTreeByLines

import java.util.Scanner; //导入方法依赖的package包/类
public static NbMenuItem parseSubTreeByLines(String filename) {
    Hashtable<Integer, NbMenuItem> levelRoots = new Hashtable<Integer, NbMenuItem>();
    NbMenuItem mainNode = new NbMenuItem();
    int actLevel = -1;
    levelRoots.put(new Integer(actLevel), mainNode);
    try {
        Scanner scanner = new Scanner(new File(filename));
        while (scanner.hasNextLine()) {
            String nextLine = scanner.nextLine();
            int spaces = 0;
            while (nextLine.charAt(spaces) == ' ') {
                spaces++;
            }
            nextLine = nextLine.substring(spaces).trim();
            NbMenuItem newNode = new NbMenuItem();
            newNode.setName(nextLine);
            actLevel = spaces / 4;//every level is intended
            //NbMenuItem node =
            ArrayList<NbMenuItem> submenu = levelRoots.get(actLevel - 1).getSubmenu();
            if (submenu == null) {
                submenu = new ArrayList<NbMenuItem>();
            }
            submenu.add(newNode);
            levelRoots.get(actLevel - 1).setSubmenu(submenu);//set new submenu with the new node in it

            levelRoots.put(actLevel, newNode);
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
    }
    return mainNode;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:Utilities.java

示例10: extractJSessionId

import java.util.Scanner; //导入方法依赖的package包/类
private String extractJSessionId(String response) {
    Scanner scanner = new Scanner(response);
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        if (line.startsWith("Set-Cookie")) {
            return Arrays.asList(line.split(":")[1].split(";"))
                    .stream()
                    .filter(s -> s.contains("JSESSIONID"))
                    .findAny()
                    .get();

        }
    }
    return null;
}
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:16,代码来源:CookieIT.java

示例11: getInstance

import java.util.Scanner; //导入方法依赖的package包/类
public static Languages getInstance(final String languagesResourceName) {
    // read languages list
    final Set<String> ls = new HashSet<String>();
    final InputStream langIS = Languages.class.getClassLoader().getResourceAsStream(languagesResourceName);

    if (langIS == null) {
        throw new IllegalArgumentException("Unable to resolve required resource: " + languagesResourceName);
    }

    final Scanner lsScanner = new Scanner(langIS, ResourceConstants.ENCODING);
    try {
        boolean inExtendedComment = false;
        while (lsScanner.hasNextLine()) {
            final String line = lsScanner.nextLine().trim();
            if (inExtendedComment) {
                if (line.endsWith(ResourceConstants.EXT_CMT_END)) {
                    inExtendedComment = false;
                }
            } else {
                if (line.startsWith(ResourceConstants.EXT_CMT_START)) {
                    inExtendedComment = true;
                } else if (line.length() > 0) {
                    ls.add(line);
                }
            }
        }
    } finally {
        lsScanner.close();
    }

    return new Languages(Collections.unmodifiableSet(ls));
}
 
开发者ID:gusavila92,项目名称:java-android-websocket-client,代码行数:33,代码来源:Languages.java

示例12: seekScannerToEnd

import java.util.Scanner; //导入方法依赖的package包/类
public static String seekScannerToEnd(Scanner scan) {
    StringBuilder data = new StringBuilder();

    while (scan.hasNextLine()) {
        data.append(scan.nextLine());
        data.append("\n");
    }

    return data.toString().trim();
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:11,代码来源:TextUtils.java

示例13: readPath

import java.util.Scanner; //导入方法依赖的package包/类
private void readPath() {
	ArrayList<PoseSteering> ret = new ArrayList<PoseSteering>();
	try {
		Scanner in = new Scanner(new FileReader(pathFileName));
		while (in.hasNextLine()) {
			String line = in.nextLine().trim();
			if (line.length() != 0 && !line.trim().startsWith("#")) {
				String[] oneline = line.split(" |\t");
				PoseSteering ps = null;
				if (oneline.length == 4) {
					ps = new PoseSteering(
							new Double(oneline[0]).doubleValue(),
							new Double(oneline[1]).doubleValue(),
							new Double(oneline[2]).doubleValue(),
							new Double(oneline[3]).doubleValue());
				}
				else {
					ps = new PoseSteering(
							new Double(oneline[0]).doubleValue(),
							new Double(oneline[1]).doubleValue(),
							new Double(oneline[2]).doubleValue(),
							0.0);					
				}
				ret.add(ps);
			}
		}
		in.close();
	}
	catch (FileNotFoundException e) { e.printStackTrace(); }
	this.path = ret;
	for (int i = 0; i < path.size(); i++) {
		Pose pose = path.get(i).getPose();
		panel.addArrow(""+i, pose, Color.gray);
	}
	panel.updatePanel();
}
 
开发者ID:FedericoPecora,项目名称:coordination_oru,代码行数:37,代码来源:PathEditor.java

示例14: modifyStartScript

import java.util.Scanner; //导入方法依赖的package包/类
@Override
protected String modifyStartScript(String content) throws RaspError {
    int modifyConfigState = NOTFOUND;
    StringBuilder sb = new StringBuilder();
    Scanner scanner = new Scanner(content);
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        if (FOUND == modifyConfigState) {
            sb.append(OPENRASP_CONFIG);
            modifyConfigState = DONE;
        }

        if (DONE == modifyConfigState) {
            if (OPENRASP_REGEX.matcher(line).matches()) {
                continue;
            }
        }

        if (line.startsWith("JAVA_OPTS=") && NOTFOUND == modifyConfigState) {
            modifyConfigState = FOUND;
        }

        sb.append(line).append(LINE_SEP);
    }
    if (NOTFOUND == modifyConfigState) {
        throw new RaspError(E10001 + "\"JAVA_OPTS=\"");
    }
    return sb.toString();
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:30,代码来源:Jboss4Installer.java

示例15: loadLocationAndPathData

import java.util.Scanner; //导入方法依赖的package包/类
/**
 * Load location and path data from a file
 * @param fileName The file to load the data from
 */
public static void loadLocationAndPathData(String fileName) {
	try {
		Scanner in = new Scanner(new FileReader(fileName));
		File f = new File(fileName);
		pathPrefix = f.getAbsolutePath().substring(0,f.getAbsolutePath().lastIndexOf(File.separator))+File.separator;
		while (in.hasNextLine()) {
			String line = in.nextLine().trim();
			if (line.length() != 0 && !line.startsWith("#")) {
				String[] oneline = line.split(" |\t");
				Pose ps = null;
				if (line.contains("->")) {
					paths.put(oneline[0]+oneline[1]+oneline[2], oneline[3]);
					System.out.println("Added to paths: " + oneline[0]+oneline[1]+oneline[2] + " --> " + oneline[3]);
				}
				else {
					String locationName = oneline[0];
					ps = new Pose(
							new Double(oneline[1]).doubleValue(),
							new Double(oneline[2]).doubleValue(),
							new Double(oneline[3]).doubleValue());
					locations.put(locationName, ps);
				}
			}
		}
		in.close();
	}
	catch (FileNotFoundException e) { e.printStackTrace(); }
}
 
开发者ID:FedericoPecora,项目名称:coordination_oru,代码行数:33,代码来源:Missions.java


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