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


Java FileUtil.getBytes方法代码示例

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


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

示例1: addMultiMedia

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
public MultiMedia addMultiMedia(MultiMedia multiMedia, File imageFile) throws SystemException, PortalException {
		long multiMediaId = CounterLocalServiceUtil.increment(MultiMedia.class.getName());
		MultiMedia model =  multiMediaPersistence.create(multiMediaId);
		model.setUserId(multiMedia.getUserId());
		model.setCompanyId(multiMedia.getCompanyId());
		model.setCreateDate(new Date());
		model.setModifiedDate(new Date());
		model.setApplicationId(multiMedia.getApplicationId());
		model.setName(multiMedia.getName());
		model.setType(multiMedia.getType());
		try {
			
//			DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, sourceFileName, mimeType, title, description, changeLog, imageFile, serviceContext);
//			DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, imageFile.getName(), mimeType, title, description, changeLog, imageFile, serviceContext);
			byte[] imageBytes = null;
			imageBytes = FileUtil.getBytes(imageFile);
			model.setImageId(counterLocalService.increment());
			_log.debug("addLink::imageBytes.length: "  + imageBytes.length);
			saveImages(model.getImageId(), imageFile, imageBytes);
		} catch (Exception e) {
			_log.info(e.toString());
		}
		return multiMediaPersistence.update(model, true);
	}
 
开发者ID:fraunhoferfokus,项目名称:govapps,代码行数:25,代码来源:MultiMediaLocalServiceImpl.java

示例2: updateMultiMedia

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
public MultiMedia updateMultiMedia(MultiMedia multiMedia, File imageFile) throws SystemException {
	MultiMedia model =  multiMediaPersistence.fetchByPrimaryKey(multiMedia.getMultiMediaId());
	model.setUserId(multiMedia.getUserId());
	model.setCompanyId(multiMedia.getCompanyId());
	model.setApplicationId(multiMedia.getApplicationId());
	model.setType(multiMedia.getType());
	model.setModifiedDate(new Date());
	try {
		byte[] imageBytes = null;
		imageBytes = FileUtil.getBytes(imageFile);
		model.setImageId(counterLocalService.increment());
		_log.debug("addLink::imageBytes.length: "  + imageBytes.length);
		_log.debug("imageFile.getName(): "  + imageFile.getName());
		model.setName(imageFile.getName());
		
		saveImages(model.getImageId(), imageFile, imageBytes);
	} catch (Exception e) {
		_log.info(e.toString());
	}
	return multiMediaPersistence.update(model, true);		
}
 
开发者ID:fraunhoferfokus,项目名称:govapps,代码行数:22,代码来源:MultiMediaLocalServiceImpl.java

示例3: migrateFile

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
protected void migrateFile(
		long repositoryId, long companyId, String name, Image image)
	throws Exception {

	InputStream is = _sourceHook.getImageAsStream(image);

	byte[] bytes = FileUtil.getBytes(is);

	if (name == null) {
		name = image.getImageId() + StringPool.PERIOD + image.getType();
	}

	if (DLStoreUtil.hasFile(companyId, repositoryId, name)) {
		DLStoreUtil.deleteFile(companyId, repositoryId, name);
	}

	DLStoreUtil.addFile(companyId, repositoryId, name, false, bytes);
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:19,代码来源:UpgradeImageGallery.java

示例4: updateServiceFileTemplate

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
public ServiceFileTemplate updateServiceFileTemplate(long userId, long groupId, long folderId, long serviceInfoId,
		String fileTemplateNo, String templateName, String sourceFileName, InputStream inputStream,
		ServiceContext serviceContext) throws PortalException, IOException {

	long fileEntryId = 0;

	if (inputStream != null) {
		String mimeType = MimeTypesUtil.getContentType(sourceFileName);
		int size = FileUtil.getBytes(inputStream).length;

		FileEntry fileEntry = dlAppLocalService.addFileEntry(userId, groupId, folderId, sourceFileName, mimeType,
				templateName, templateName, StringPool.BLANK, inputStream, size, serviceContext);

		fileEntryId = fileEntry.getFileEntryId();
	}

	ServiceFileTemplatePK fileTemplatePK = new ServiceFileTemplatePK(serviceInfoId, fileTemplateNo);

	ServiceFileTemplate serviceFileTemplate = serviceFileTemplatePersistence.fetchByPrimaryKey(fileTemplatePK);

	// remove old fileEntry
	if (serviceFileTemplate.getFileEntryId() != 0) {
		dlAppLocalService.deleteFileEntry(serviceFileTemplate.getFileEntryId());
	}

	serviceFileTemplate.setTemplateName(templateName);
	serviceFileTemplate.setFileEntryId(fileEntryId);

	return serviceFileTemplatePersistence.update(serviceFileTemplate);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:31,代码来源:ServiceFileTemplateLocalServiceImpl.java

示例5: addServiceFileTemplate

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
public ServiceFileTemplate addServiceFileTemplate(long userId, long groupId, long folderId, long serviceInfoId,
		String fileTemplateNo, String templateName, String sourceFileName, InputStream inputStream,
		ServiceContext serviceContext) throws PortalException, IOException {

	long fileEntryId = 0;

	serviceContext.setAddGroupPermissions(true);
	serviceContext.setAddGuestPermissions(true);

	if (inputStream != null) {
		String mimeType = MimeTypesUtil.getContentType(sourceFileName);
		int size = FileUtil.getBytes(inputStream).length;

		// FileEntry fileEntry =
		//
		// dlAppLocalService.addFileEntry(userId, groupId, folderId,
		// sourceFileName, mimeType,
		// sourceFileName, sourceFileName, sourceFileName,
		// inputStream, size, serviceContext);
		
		try {
			FileEntry fileEntry = dlAppLocalService.addFileEntry(userId, groupId, folderId, sourceFileName, mimeType,
					sourceFileName, sourceFileName, sourceFileName, inputStream, size, serviceContext);

			fileEntryId = fileEntry.getFileEntryId();
		} catch (Exception e) {
			_log.error(e);
		}
		
		
	}

	ServiceFileTemplatePK fileTemplatePK = new ServiceFileTemplatePK(serviceInfoId, fileTemplateNo);

	ServiceFileTemplate serviceFileTemplate = serviceFileTemplatePersistence.create(fileTemplatePK);

	serviceFileTemplate.setTemplateName(templateName);
	serviceFileTemplate.setFileEntryId(fileEntryId);

	return serviceFileTemplatePersistence.update(serviceFileTemplate);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:42,代码来源:ServiceFileTemplateLocalServiceImpl.java

示例6: getFileBytes

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
public static byte[] getFileBytes(String path) throws IOException {
    return FileUtil.getBytes(getFileStream(path));
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:4,代码来源:ResourcesUtil.java

示例7: updateApplication

import com.liferay.portal.kernel.util.FileUtil; //导入方法依赖的package包/类
public Application updateApplication(Application application, File imageFile) throws SystemException, PortalException {
		
		Application model =  applicationPersistence.fetchByPrimaryKey(application.getApplicationId());
		model.setCompanyId(application.getCompanyId());
//		model.setCreateDate(new Date());
		model.setDescription(application.getDescription());
		model.setFee(application.getFee());
		model.setTargetCategory(application.getTargetCategory());
		model.setDeveloper(application.getDeveloper());
		model.setFirstPublishingDate(application.getFirstPublishingDate());
		model.setLastModifiedDate(application.getLastModifiedDate());
		model.setLifeCycleStatus(application.getLifeCycleStatus());
//		model.setLifeCycleStatusString("geändert - warten auf Freigabe");

		try {
			_log.debug("imageFile.getName(): " + imageFile.getName());
			byte[] imageBytes = null;
			imageBytes = FileUtil.getBytes(imageFile);		
			
			if(imageBytes!=null) {
				_log.debug("updateApplication::imageBytes.length: "  + imageBytes.length);
				if (imageBytes.length > 0) {
					model.setLogoImageId(counterLocalService.increment());
					saveImages(model.getLogoImageId(), imageFile, imageBytes);				
				} else {
					_log.debug("updateApplication::imageBytes.length == 0");
					_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
//					model.setLogoImageId(model.getLogoImageId());
				} 
			} else {
				_log.debug("updateApplication::imageBytes == null! ");	
				_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
//				model.setLogoImageId(model.getLogoImageId());
			}
		} catch (Exception e) {
			_log.debug(e.getMessage());
		}
		_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
		model.setMinTargetOSVersion(application.getMinTargetOSVersion());
		model.setModifiedDate(new Date());
		model.setName(application.getName());
		model.setSize(application.getSize());
		model.setTargetOS(application.getTargetOS());
		model.setUserId(application.getUserId());
		if (application.getLifeCycleStatus() >= Constants.APPLICATION_STATUS_VERIFIED ) {
			model.setVerifiedDate(application.getVerifiedDate());			
		}
		model.setVersion(application.getVersion());
		model.setVersionInformation(application.getVersionInformation());
		model.setLegalDetails(application.getLegalDetails());
        // Indexer
        Indexer indexer = IndexerRegistryUtil.getIndexer(Application.class);
        indexer.reindex(model);
		model = applicationPersistence.update(model, true);
		_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
		return model;			
	}
 
开发者ID:fraunhoferfokus,项目名称:govapps,代码行数:58,代码来源:ApplicationLocalServiceImpl.java


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