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


Java LineNumberReader.ready方法代码示例

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


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

示例1: compareOutput

import java.io.LineNumberReader; //导入方法依赖的package包/类
protected boolean compareOutput(Reader expected, Reader actual) throws IOException {
    LineNumberReader expectedOutput = new LineNumberReader(expected);
    LineNumberReader actualOutput = new LineNumberReader(actual);

    while (expectedOutput.ready() && actualOutput.ready()) {
        String expectedLine = expectedOutput.readLine();
        String actualLine = actualOutput.readLine();
        if (!expectedLine.equals(actualLine)) {
            System.out.println("Entityreference expansion failed, line no: " + expectedOutput.getLineNumber());
            System.out.println("Expected: " + expectedLine);
            System.out.println("Actual  : " + actualLine);
            return false;
        }
    }
    expectedOutput.close();
    actualOutput.close();
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:EntityTest.java

示例2: testReadFileFromJarfile

import java.io.LineNumberReader; //导入方法依赖的package包/类
/**
 *
 */
public void testReadFileFromJarfile() throws IOException {
    String catalog0 = this.catalog.serialize();
    assertTrue(catalog0.length() > 0);

    String catalog1 = JarReader.readFileFromJarfile(this.jarPath.getAbsolutePath(), CatalogUtil.CATALOG_FILENAME);
    assertTrue(catalog1.length() > 0);

    assertEquals(catalog0.length(), catalog1.length());

    LineNumberReader reader0 = new LineNumberReader(new CharArrayReader(catalog0.toCharArray()));
    LineNumberReader reader1 = new LineNumberReader(new CharArrayReader(catalog1.toCharArray()));

    try {
        int lines = 0;
        while (reader0.ready()) {
            assertEquals(reader0.ready(), reader1.ready());
            assertEquals(reader0.readLine(), reader1.readLine());
            lines++;
        }
        assertTrue(lines > 0);
        reader0.close();
        reader1.close();
    } catch (Exception ex) {
        ex.printStackTrace();
        assertTrue(false);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:31,代码来源:TestJarReader.java

示例3: call

import java.io.LineNumberReader; //导入方法依赖的package包/类
@Override
protected String call() throws Exception 
{		
	try
	{
		LineNumberReader reader = new LineNumberReader(new FileReader(file));
		ObservableList<DupData> tableDataModel = FXCollections.<DupData> observableArrayList();
		Map<String, String> deviceMap = new HashMap<String, String>();
		
		try
		{
			int txtLen = 0;
			
			while(reader.ready())
			{
				String line = reader.readLine();
				String[] group  = dupPattern.split(line.subSequence(0, line.length()));
				
				if(group.length > 0)
				{
					if(group.length == 3 && group[0].equals("data"))
						deviceMap.put(group[1], group[2]);
					else if(group.length == 7 && group[0].equals("dup"))
					{
						String[] devices = new String[2];
						String[] files = new String[2];
						int[] offsets = new int[2];
						
						devices[0] = group[1];
						devices[1] = group[3];
						
						files[0] = group[2];
						files[1] = group[4];
						
						offsets[0] = txtLen;
						offsets[1] = txtLen + line.length();
		
						tableDataModel.add(new DupData(devices, files, Long.parseLong(group[5]), offsets));
					}
				}
				
				txtLen += line.length();
				txtLen++; // increment needed for line feed.
				buff.append(line).append("\n");
			}
		}
		finally
		{
			reader.close();
		}
		
		Map<BooleanPropertyBase, BooleanPropertyBase> booleanPropertyMap  = new HashMap<>();;
		List<BooleanPropertyBase> booleanLeftPropertyList = new ArrayList<>(tableDataModel.size());
		List<BooleanPropertyBase> booleanRightPropertyList = new ArrayList<>(tableDataModel.size());
		
		for(int i = 0; i < tableDataModel.size(); i++)
		{
			BooleanPropertyBase propertyLeft = new SimpleBooleanProperty();
			BooleanPropertyBase propertyRight = new SimpleBooleanProperty();
			
			booleanLeftPropertyList.add(propertyLeft);
			booleanRightPropertyList.add(propertyRight);
			
			booleanPropertyMap.put(propertyLeft, propertyRight);
			booleanPropertyMap.put(propertyRight, propertyLeft);
		}
		
		ObjectEventDispatcher.postObject(new ObservableDataContainer(tableDataModel, booleanLeftPropertyList, booleanRightPropertyList, booleanPropertyMap, deviceMap));
		
		return buff.toString();
	}
	catch(Exception e)
	{
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		e.printStackTrace(new PrintStream(stream));
		
		return stream.toString();
	}
}
 
开发者ID:tengai650,项目名称:SnapDup,代码行数:80,代码来源:DupParserTask.java

示例4: testContainerLaunch

import java.io.LineNumberReader; //导入方法依赖的package包/类
@Test
public void testContainerLaunch() throws IOException {
  String appSubmitter = "nobody";
  String appId = "APP_ID";
  String containerId = "CONTAINER_ID";
  String testImage = "\"sequenceiq/hadoop-docker:2.4.1\"";

  Container container = mock(Container.class, RETURNS_DEEP_STUBS);
  ContainerId cId = mock(ContainerId.class, RETURNS_DEEP_STUBS);
  ContainerLaunchContext context = mock(ContainerLaunchContext.class);
  HashMap<String, String> env = new HashMap<String,String>();

  when(container.getContainerId()).thenReturn(cId);
  when(container.getLaunchContext()).thenReturn(context);
  when(cId.getApplicationAttemptId().getApplicationId().toString()).thenReturn(appId);
  when(cId.toString()).thenReturn(containerId);

  when(context.getEnvironment()).thenReturn(env);
  env.put(YarnConfiguration.NM_DOCKER_CONTAINER_EXECUTOR_IMAGE_NAME, testImage);
  Path scriptPath = new Path("file:///bin/echo");
  Path tokensPath = new Path("file:///dev/null");

  Path pidFile = new Path(workDir, "pid");

  dockerContainerExecutor.activateContainer(cId, pidFile);
  int ret = dockerContainerExecutor.launchContainer(
      new ContainerStartContext.Builder()
          .setContainer(container)
          .setNmPrivateContainerScriptPath(scriptPath)
          .setNmPrivateTokensPath(tokensPath)
          .setUser(appSubmitter)
          .setAppId(appId)
          .setContainerWorkDir(workDir)
          .setLocalDirs(dirsHandler.getLocalDirs())
          .setLogDirs(dirsHandler.getLogDirs())
          .build());
  assertEquals(0, ret);
  //get the script
  Path sessionScriptPath = new Path(workDir,
      Shell.appendScriptExtension(
          DockerContainerExecutor.DOCKER_CONTAINER_EXECUTOR_SESSION_SCRIPT));
  LineNumberReader lnr = new LineNumberReader(new FileReader(sessionScriptPath.toString()));
  boolean cmdFound = false;
  List<String> localDirs = dirsToMount(dirsHandler.getLocalDirs());
  List<String> logDirs = dirsToMount(dirsHandler.getLogDirs());
  List<String> workDirMount = dirsToMount(Collections.singletonList(workDir.toUri().getPath()));
  List<String> expectedCommands =  new ArrayList<String>(
      Arrays.asList(DOCKER_LAUNCH_COMMAND, "run", "--rm", "--net=host",  "--name", containerId));
  expectedCommands.addAll(localDirs);
  expectedCommands.addAll(logDirs);
  expectedCommands.addAll(workDirMount);
  String shellScript =  workDir + "/launch_container.sh";

  expectedCommands.addAll(Arrays.asList(testImage.replaceAll("['\"]", ""), "bash","\"" + shellScript + "\""));

  String expectedPidString = "echo `/bin/true inspect --format {{.State.Pid}} " + containerId+"` > "+ pidFile.toString() + ".tmp";
  boolean pidSetterFound = false;
  while(lnr.ready()){
    String line = lnr.readLine();
    LOG.debug("line: " + line);
    if (line.startsWith(DOCKER_LAUNCH_COMMAND)){
      List<String> command = new ArrayList<String>();
      for( String s :line.split("\\s+")){
        command.add(s.trim());
      }

      assertEquals(expectedCommands, command);
      cmdFound = true;
    } else if (line.startsWith("echo")) {
      assertEquals(expectedPidString, line);
      pidSetterFound = true;
    }

  }
  assertTrue(cmdFound);
  assertTrue(pidSetterFound);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:78,代码来源:TestDockerContainerExecutorWithMocks.java


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