當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。