本文整理汇总了Java中com.liferay.portal.kernel.util.FileUtil类的典型用法代码示例。如果您正苦于以下问题:Java FileUtil类的具体用法?Java FileUtil怎么用?Java FileUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileUtil类属于com.liferay.portal.kernel.util包,在下文中一共展示了FileUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importContactsInBackground
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
@Override
public long importContactsInBackground(long userId, ExportImportConfiguration exportImportConfiguration,
InputStream inputStream, String extension) throws PortalException {
File file = null;
try {
file = FileUtil.createTempFile(extension);
FileUtil.write(file, inputStream);
return importContactsInBackground(userId, exportImportConfiguration, file);
} catch (IOException ioe) {
throw new SystemException(ioe);
} finally {
FileUtil.delete(file);
}
}
示例2: importTaskRecords
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
@Override
public void importTaskRecords(ExportImportConfiguration exportImportConfiguration, InputStream inputStream)
throws PortalException {
File file = null;
try {
file = FileUtil.createTempFile("lar");
FileUtil.write(file, inputStream);
importTaskRecords(exportImportConfiguration, file);
} catch (IOException ioe) {
throw new SystemException(ioe);
} finally {
FileUtil.delete(file);
}
}
示例3: importContacts
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
@Override
public void importContacts(ExportImportConfiguration exportImportConfiguration, InputStream inputStream)
throws PortalException {
File file = null;
try {
file = FileUtil.createTempFile("lar");
FileUtil.write(file, inputStream);
importContacts(exportImportConfiguration, file);
} catch (IOException ioe) {
throw new SystemException(ioe);
} finally {
FileUtil.delete(file);
}
}
示例4: uploadPhoto
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
@Override
public File uploadPhoto(long userId, long companyId, long groupId, long id, InputStream inputStream,
String fileName, String fileType, long fileSize, String destination, String desc,
ServiceContext serviceContext) throws Exception {
File file = null;
FileEntry fileEntry = FileUploadUtils.uploadFile(userId, companyId, groupId, inputStream, fileName, fileType,
fileSize, destination, desc, serviceContext);
User user = UserLocalServiceUtil.fetchUser(id);
file = DLFileEntryLocalServiceUtil.getFile(fileEntry.getFileEntryId(), fileEntry.getVersion(), false);
UserLocalServiceUtil.updatePortrait(user.getUserId(), FileUtil.getBytes(file));
return file;
}
示例5: importMeasurements
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
@Override
public void importMeasurements(
ExportImportConfiguration exportImportConfiguration,
InputStream inputStream) throws PortalException {
_log.info("importMeasurements()");
File file = null;
try {
// TODO: use extension from upload
file = FileUtil.createTempFile("lar");
FileUtil.write(file, inputStream);
importMeasurements(exportImportConfiguration, file);
} catch (IOException ioe) {
throw new SystemException(ioe);
} finally {
FileUtil.delete(file);
}
}
示例6: importMeasurementsInBackground
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
@Override
public long importMeasurementsInBackground(long userId,
ExportImportConfiguration exportImportConfiguration,
InputStream inputStream, String extension) throws PortalException {
_log.info("importMeasurementsInBackground()");
File file = null;
try {
file = FileUtil.createTempFile(extension);
FileUtil.write(file, inputStream);
return importMeasurementsInBackground(userId,
exportImportConfiguration, file);
} catch (IOException ioe) {
throw new SystemException(ioe);
} finally {
FileUtil.delete(file);
}
}
示例7: 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);
}
示例8: 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);
}
示例9: importLayouts
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
private void importLayouts(long userId,Group grupo,LayoutSetPrototype lsProto) throws PortalException, SystemException
{
LayoutSet ls = lsProto.getLayoutSet();
Map<String, String[]> parameterMap =getLayoutSetPrototypeParameters();
File fileIni= layoutLocalService.exportLayoutsAsFile(ls.getGroupId(), true,
null,parameterMap, null, null);
try
{
layoutLocalService.importLayouts(userId, grupo.getPublicLayoutSet().getGroupId(),
grupo.getPublicLayoutSet().isPrivateLayout(),
parameterMap, fileIni);
}
catch(Exception e)
{
}
FileUtil.delete(fileIni);
}
示例10: deleteExportedCourse
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
public void deleteExportedCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = ParamUtil.getLong(actionRequest, "groupId", 0);
String fileName = ParamUtil.getString(actionRequest, "fileName", StringPool.BLANK);
String redirect = ParamUtil.getString(actionRequest, "redirect", StringPool.BLANK);
File f = new File(PropsUtil.get("liferay.home")+"/data/lms_exports/courses/"+themeDisplay.getCompanyId()+"/"+groupId+"/"+fileName);
if (themeDisplay.getPermissionChecker().hasPermission(groupId, Course.class.getName(), groupId, ActionKeys.DELETE) && f != null && f.isFile()) {
FileUtil.delete(f);
SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.success");
} else {
SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.error");
}
if (Validator.isNotNull(redirect)) {
actionResponse.sendRedirect(redirect);
}
}
示例11: 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);
}
示例12: buildSQLFile
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
public void buildSQLFile(String sqlDir, String fileName)
throws IOException {
String template = buildTemplate(sqlDir, fileName);
if (Validator.isNull(template)) {
return;
}
template = buildSQL(template);
FileUtil.write(
sqlDir + "/" + fileName + "/" + fileName + "-" + getServerName() +
".sql",
template);
}
示例13: addDDMStructures
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
protected void addDDMStructures(
String parentStructureId, String structuresDirName)
throws Exception {
Set<String> resourcePaths = servletContext.getResourcePaths(
resourcesDir.concat(structuresDirName));
if (resourcePaths == null) {
return;
}
for (String resourcePath : resourcePaths) {
if (resourcePath.endsWith(StringPool.SLASH)) {
continue;
}
String name = FileUtil.getShortFileName(resourcePath);
URL url = servletContext.getResource(resourcePath);
URLConnection urlConnection = url.openConnection();
addDDMStructures(
parentStructureId, name, urlConnection.getInputStream());
}
}
示例14: addDDMTemplates
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
protected void addDDMTemplates(
String ddmStructureKey, String templatesDirName)
throws Exception {
Set<String> resourcePaths = servletContext.getResourcePaths(
resourcesDir.concat(templatesDirName));
if (resourcePaths == null) {
return;
}
for (String resourcePath : resourcePaths) {
if (resourcePath.endsWith(StringPool.SLASH)) {
continue;
}
String name = FileUtil.getShortFileName(resourcePath);
URL url = servletContext.getResource(resourcePath);
URLConnection urlConnection = url.openConnection();
addDDMTemplates(
ddmStructureKey, name, urlConnection.getInputStream());
}
}
示例15: addDLFileEntry
import com.liferay.portal.kernel.util.FileUtil; //导入依赖的package包/类
protected void addDLFileEntry(String resourcePath) throws Exception {
Long parentFolderId = _folderIds.get(
FileUtil.getPath(resourcePath) + StringPool.SLASH);
if (parentFolderId == null) {
parentFolderId = 0L;
}
URL url = servletContext.getResource(resourcePath);
URLConnection urlConnection = url.openConnection();
addDLFileEntry(
parentFolderId, FileUtil.getShortFileName(resourcePath),
urlConnection.getInputStream(), urlConnection.getContentLength());
}