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


Java Arrays类代码示例

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


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

示例1: testContainerKill

import java.util.Arrays; //导入依赖的package包/类
@Test
public void testContainerKill() throws IOException {
  String appSubmitter = "nobody";
  String cmd = String.valueOf(
      PrivilegedOperation.RunAsUserCommand.SIGNAL_CONTAINER.getValue());
  ContainerExecutor.Signal signal = ContainerExecutor.Signal.QUIT;
  String sigVal = String.valueOf(signal.getValue());

  Container container = mock(Container.class);
  ContainerId cId = mock(ContainerId.class);
  ContainerLaunchContext context = mock(ContainerLaunchContext.class);

  when(container.getContainerId()).thenReturn(cId);
  when(container.getLaunchContext()).thenReturn(context);

  mockExec.signalContainer(new ContainerSignalContext.Builder()
      .setContainer(container)
      .setUser(appSubmitter)
      .setPid("1000")
      .setSignal(signal)
      .build());
  assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
      appSubmitter, cmd, "1000", sigVal),
      readMockParams());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestLinuxContainerExecutorWithMocks.java

示例2: hasEqualMd5

import java.util.Arrays; //导入依赖的package包/类
private boolean hasEqualMd5(Path localFile, byte[] md5) {
	try {
		Path relativeToBase = appConfig.getSyncPath().relativize(localFile);
		LOGGER.debug("Comparing MD5s for file '{}'...", localFile);
		byte[] localMd5 = computeMd5(localFile);
		if (Arrays.equals(md5, localMd5)) {
			LOGGER.debug("Equal MD5s, skipping upload/download.");
			return false;
		}
	} catch (IOException e) {
		LOGGER.debug("Error while computing MD5...");
		LogUtil.stacktrace(LOGGER, e);
	}
	LOGGER.debug("Differing MD5s, uploading/downloading...");
	return true;
}
 
开发者ID:Azzurite,项目名称:MinecraftServerSync,代码行数:17,代码来源:FTPSyncClient.java

示例3: testLoadClasspath

import java.util.Arrays; //导入依赖的package包/类
@Test
public void testLoadClasspath() throws IOException {
    String path = Paths.get(new File(".").getCanonicalPath(), "src", "test", "resources", "gson-2.2.4.jar").toString();
    SourceClass sourceClass = new SourceClass("teste", "Teste", "package teste; import com.google.gson.Gson; public class Teste {}");
    MemoryClassCompiler compiler = new MemoryClassCompiler(Arrays.asList(path));
    try {
        compiler.compile(sourceClass);
    } catch (Exception ex) {
        Assert.assertFalse(true);
    }
}
 
开发者ID:schmittjoaopedro,项目名称:mcc,代码行数:12,代码来源:SimpleCompilerTest.java

示例4: springBeanPointcut

import java.util.Arrays; //导入依赖的package包/类
/**
 * Advice that logs when a method is entered and exited.
 *
 * @param joinPoint join point for advice
 * @return result
 * @throws Throwable throws IllegalArgumentException
 */
@Around("applicationPackagePointcut() && springBeanPointcut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
    if (log.isDebugEnabled()) {
        log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
    }
    try {
        Object result = joinPoint.proceed();
        if (log.isDebugEnabled()) {
            log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(),
                joinPoint.getSignature().getName(), result);
        }
        return result;
    } catch (IllegalArgumentException e) {
        log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()),
            joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());

        throw e;
    }
}
 
开发者ID:michaelhoffmantech,项目名称:patient-portal,代码行数:28,代码来源:LoggingAspect.java

示例5: createTable

import java.util.Arrays; //导入依赖的package包/类
/**
 * @param dropIfExists
 */
public void createTable(boolean dropIfExists) throws IOException {
  if (admin.tableExists(secondaryTableName)) {
    if (dropIfExists) {
      admin.disableTable(bucketTableName);
      admin.deleteTable(bucketTableName);
      admin.disableTable(secondaryTableName);
      admin.deleteTable(secondaryTableName);
    } else {
      secondaryTable = conn.getTable(secondaryTableName);
      bucketTable = conn.getTable(bucketTableName);
      return;
    }
  }
  // secondary table
  HTableDescriptor secondaryDesc = new HTableDescriptor(secondaryTableName);
  secondaryDesc
      .addFamily(IndexTableRelation.getDefaultColumnDescriptor(MDHBaseAdmin.SECONDARY_FAMILY));
  admin.createTable(secondaryDesc);
  secondaryTable = conn.getTable(secondaryTableName);
  // bucket table
  HTableDescriptor bucketDesc = new HTableDescriptor(bucketTableName);
  bucketDesc.addFamily(IndexTableRelation.getDefaultColumnDescriptor(MDHBaseAdmin.BUCKET_FAMILY));
  admin.createTable(bucketDesc);
  bucketTable = conn.getTable(bucketTableName);
  // init when init
  int[] starts = new int[dimensions];
  Arrays.fill(starts, 0);
  Put put = new Put(MDUtils.bitwiseZip(starts, dimensions));
  put.addColumn(MDHBaseAdmin.BUCKET_FAMILY, MDHBaseAdmin.BUCKET_PREFIX_LEN_QUALIFIER,
      Bytes.toBytes(dimensions));
  put.addColumn(MDHBaseAdmin.BUCKET_FAMILY, MDHBaseAdmin.BUCKET_SIZE_QUALIFIER,
      Bytes.toBytes(0L));
  bucketTable.put(put);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:MDIndex.java

示例6: containsAnyUuid

import java.util.Arrays; //导入依赖的package包/类
/**
 * Returns true if there any common ParcelUuids in uuidA and uuidB.
 *
 * @param uuidA - List of ParcelUuids
 * @param uuidB - List of ParcelUuids
 */
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) return true;

    if (uuidA == null) {
        return uuidB.length == 0;
    }

    if (uuidB == null) {
        return uuidA.length == 0;
    }

    HashSet<ParcelUuid> uuidSet = new HashSet<>(Arrays.asList(uuidA));
    for (ParcelUuid uuid : uuidB) {
        if (uuidSet.contains(uuid)) return true;
    }
    return false;
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:24,代码来源:BluetoothUuidCompat.java

示例7: retainAll

import java.util.Arrays; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean retainAll( long[] array ) {
    boolean changed = false;
    Arrays.sort( array );
    long[] set = _set;
    byte[] states = _states;

    _autoCompactTemporaryDisable = true;
    for ( int i = set.length; i-- > 0; ) {
        if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) {
            removeAt( i );
            changed = true;
        }
    }
    _autoCompactTemporaryDisable = false;

    return changed;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:19,代码来源:TLongHashSet.java

示例8: startEdit

import java.util.Arrays; //导入依赖的package包/类
/** Create a private, writable copy of names.
 *  Preserve the original copy, for reference.
 */
void startEdit() {
    assert(verifyArity());
    int oc = ownedCount();
    assert(!inTrans());  // no nested transactions
    flags |= F_TRANS;
    Name[] oldNames = names;
    Name[] ownBuffer = (oc == 2 ? originalNames : null);
    assert(ownBuffer != oldNames);
    if (ownBuffer != null && ownBuffer.length >= length) {
        names = copyNamesInto(ownBuffer);
    } else {
        // make a new buffer to hold the names
        final int SLOP = 2;
        names = Arrays.copyOf(oldNames, Math.max(length + SLOP, oldNames.length));
        if (oc < 2)  ++flags;
        assert(ownedCount() == oc + 1);
    }
    originalNames = oldNames;
    assert(originalNames != names);
    firstChange = length;
    assert(inTrans());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:LambdaFormBuffer.java

示例9: build

import java.util.Arrays; //导入依赖的package包/类
@Override
public CreateContainerCmd build(TestDescriptor td, CreateContainerCmd cmd, Volume v) {
	Bind[] binds = cmd.getBinds();
	
	String hostPath = v.useClasspath() 
			? Thread.currentThread().getContextClassLoader()
					.getResource(v.host()).getPath()
			: v.host();
	
	Bind bind = new Bind(hostPath, 
			new com.github.dockerjava.api.model.Volume(v.container()), 
			AccessMode.fromBoolean(v.accessMode().equals(Volume.AccessMode.RW)));
	
	List<Bind> bindsList = new ArrayList<>();
	if(binds != null) {
		bindsList.addAll(Arrays.asList(binds));
	} 
	bindsList.add(bind);  	
    return cmd.withBinds(bindsList);
}
 
开发者ID:qzagarese,项目名称:dockerunit,代码行数:21,代码来源:VolumeExtensionInterpreter.java

示例10: sendAlarmOnlyOnMailSubscriptionTarget

import java.util.Arrays; //导入依赖的package包/类
@Test
public void sendAlarmOnlyOnMailSubscriptionTarget() {
    Alarm alarm = TestUtils.getDefaultAlarm();
    Subscription s1 = TestUtils.getDefaultSubscription();
    Subscription s2 = TestUtils.getDefaultSubscription();
    s2.setTarget("/dev/null");
    s2.setType(SubscriptionType.SHELL);

    alarm.setSubscriptions(Arrays.asList(s1, s2));

    Map<String, String> model = new HashMap<>();
    model.put("status", "disabled");
    model.put("alert", alarm.getName());
    model.put("link", dashboardTestBaseUrl + "/notifications/" + alarm.getId());

    List<String> recipients = Collections.singletonList(s1.getTarget());

    notificationHandler.sendAlarmHasBeenDeactivated(alarm);

    verify(senderMock).send("One of your alerts has been disabled",notificationHandler.processTemplate("checkModified.vm", model),recipients);
}
 
开发者ID:voyages-sncf-technologies,项目名称:cerebro,代码行数:22,代码来源:NotificationHandlerTest.java

示例11: rotate4

import java.util.Arrays; //导入依赖的package包/类
@Test
public void rotate4() throws Exception {
    int[][] input = {
            {1, 2, 3, 4},
            {5, 6, 7, 8},
            {9, 10, 11, 12},
            {13, 14, 15, 16}
    };

    int[][] expected = {
            {13, 9, 5, 1},
            {14, 10, 6, 2},
            {15, 11, 7, 3},
            {16, 12, 8, 4}
    };

    int[][] output = testInstance.rotate(input);

    assertTrue(Arrays.deepEquals(expected, output));
}
 
开发者ID:rostykerei,项目名称:cci,代码行数:21,代码来源:RotateMatrixAbstractTest.java

示例12: testRenameFileChangeCase_DO

import java.util.Arrays; //导入依赖的package包/类
public void testRenameFileChangeCase_DO () throws Exception {
    // prepare
    File fromFile = createFile("file");
    File toFile = new File(getWorkTreeDir(), "FILE");
    commit(fromFile);
    
    // move
    renameDO(fromFile, toFile.getName());
    
    // test
    if (Utilities.isWindows() || Utilities.isMac()) {
        assertTrue(Arrays.asList(toFile.getParentFile().list()).contains(toFile.getName()));
        assertFalse(Arrays.asList(fromFile.getParentFile().list()).contains(fromFile.getName()));
    } else {
        assertFalse(fromFile.exists());
        assertTrue(toFile.exists());
        assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, getCache().refresh(fromFile).getStatus());
        assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, getCache().refresh(toFile).getStatus());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:InterceptorTest.java

示例13: propertiesModified

import java.util.Arrays; //导入依赖的package包/类
public boolean propertiesModified() throws IOException {        
    Map<String, byte[]> baseProps = getBaseSvnProperties();
    Map<String, byte[]> props = getWorkingSvnProperties();
    if ((baseProps == null) && (props != null)) {
        return true;
    }
    if ((baseProps != null) && (props == null)) {
        return true;
    }
    if ((baseProps == null) && (props == null)) {
        return false;
    }        
    if(baseProps.size() != props.size()) {
        return true;
    }
    for(Map.Entry<String, byte[]> baseEntry : baseProps.entrySet()) {
        byte[] propsValue = props.get(baseEntry.getKey());            
        if(propsValue == null || !Arrays.equals(propsValue, baseEntry.getValue())) {
            return true;
        }                        
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:WorkingCopyDetails.java

示例14: newData

import java.util.Arrays; //导入依赖的package包/类
@Override
public void newData(byte[] data) {
	tracker.updateData = false;
	if(data[0] == EXECUTE_START){
		String command = new String(data, 1, data.length - 1);
		
		newCommand = command;
		newCommandReceived = true;
	}else if(data[0] == EXECUTE_STOP){
		stopExecution = true;
	}
	else if(data[0] == OUTPUT_STREAM_UPDATE){
		outputStreamData = Arrays.copyOfRange(data, 1, outputStreamData.length - 1);
		outputStreamUpdated = true;
	}
	tracker.updateData = true;
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:18,代码来源:LocalShell.java

示例15: LibrariesNode

import java.util.Arrays; //导入依赖的package包/类
/**
 * Creates new LibrariesNode named displayName displaying classPathProperty classpath
 * and optionaly Java platform.
 * @param displayName the display name of the node
 * @param eval {@link PropertyEvaluator} used for listening
 * @param helper {@link UpdateHelper} used for reading and updating project's metadata
 * @param refHelper {@link ReferenceHelper} used for destroying unused references
 * @param classPathProperty the ant property name of classpath which should be visualized
 * @param classPathIgnoreRef the array of ant property names which should not be displayed, may be
 * an empty array but not null
 * @param platformProperty the ant name property holding the Web platform system name or null
 * if the platform should not be displayed
 * @param librariesNodeActions actions which should be available on the created node.
 */
public LibrariesNode (String displayName, Project project, PropertyEvaluator eval, UpdateHelper helper, ReferenceHelper refHelper,
               String classPathProperty, String[] classPathIgnoreRef, String platformProperty,
               Action[] librariesNodeActions, String webModuleElementName, ClassPathSupport cs,
               Callback extraKeys) {
    this(
        displayName,
        project,
        eval,
        helper,
        refHelper,
        Collections.singletonList(classPathProperty),
        Arrays.asList(classPathIgnoreRef),
        platformProperty == null ?
            null :
            Pair.<Pair<String,String>,ClassPath>of(Pair.<String,String>of(platformProperty, null),null),
        null,
        Collections.emptySet(),
        librariesNodeActions,
        webModuleElementName,
        cs,
        extraKeys,
        null,
        null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:LibrariesNode.java


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