Java Code Examples for org.apache.wicket.util.io.IOUtils#copy()

The following examples show how to use org.apache.wicket.util.io.IOUtils#copy() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public IResource getResource() {
	ConcatBundleResource bundleResource = new ConcatBundleResource(getProvidedResources()) {

		@Override
		protected byte[] readAllResources(List<IResourceStream> resources)
				throws IOException, ResourceStreamNotFoundException {
			ByteArrayOutputStream output = new ByteArrayOutputStream();
			for (IResourceStream curStream : resources) {
				IOUtils.copy(curStream.getInputStream(), output);
				output.write("\n".getBytes());
			}

			byte[] bytes = output.toByteArray();

			if (getCompressor() != null) {
				String nonCompressed = new String(bytes, "UTF-8");
				bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
			}

			return bytes;
		}
		
	};
	ITextResourceCompressor compressor = getCompressor();
	if (compressor != null) {
		bundleResource.setCompressor(compressor);
	}
	return bundleResource;
}
 
Example 2
@Override
public IResource getResource() {
	ConcatBundleResource bundleResource = new ConcatBundleResource(getProvidedResources()) {

		@Override
		protected byte[] readAllResources(List<IResourceStream> resources)
				throws IOException, ResourceStreamNotFoundException {
			ByteArrayOutputStream output = new ByteArrayOutputStream();
			for (IResourceStream curStream : resources) {
				IOUtils.copy(curStream.getInputStream(), output);
				output.write(";\n".getBytes());
			}

			byte[] bytes = output.toByteArray();

			if (getCompressor() != null) {
				String nonCompressed = new String(bytes, "UTF-8");
				bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
			}

			return bytes;
		}
		
	};
	ITextResourceCompressor compressor = getCompressor();
	if (compressor != null) {
		bundleResource.setCompressor(compressor);
	}
	return bundleResource;
}
 
Example 3
/**
   * Download Orienteer artifacts from server.
   * @return list of {@link OArtifact} from server
   * @throws IOException 
   */
  public static List<OArtifact> getOrienteerArtifactsFromServer() throws IOException  {
  	
  	URL website = new URL(initUtils.getOrienteerModulesUrl());
  	File localFile = new File(initUtils.getPathToModulesFolder().toFile(), "modules.xml");
  	FileOutputStream fos = new FileOutputStream(localFile);
  	try {
  		IOUtils.copy(website.openStream(), fos);
  	} finally {
	fos.close();
}
  	
      OrienteerArtifactsReader reader = new OrienteerArtifactsReader(localFile.toPath());
      List<OArtifact> ooArtifacts = reader.readArtifacts();
      List<OArtifact> metadataModules = getOArtifactsMetadataAsList();
      for (OArtifact metadataModule : metadataModules) {
          for (OArtifact module : ooArtifacts) {
              OArtifactReference metadataArtifact = metadataModule.getArtifactReference();
              OArtifactReference moduleArtifact = module.getArtifactReference();
              if (metadataArtifact.getGroupId().equals(moduleArtifact.getGroupId()) &&
                      metadataArtifact.getArtifactId().equals(moduleArtifact.getArtifactId())) {
                  module.setDownloaded(true);
              }
          }
      }
      addAvailableVersions(ooArtifacts);
      return ooArtifacts;
  }