• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onRequest

import org.apache.wicket.util.file.File; //导入依赖的package包/类
public void onRequest() {
	final File file = initFile();	
	IResourceStream resourceStream = new FileResourceStream(new File(file));
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
			new ResourceStreamRequestHandler(resourceStream) {

                   @Override
				public void respond(IRequestCycle requestCycle) {
                       try {
					    super.respond(requestCycle);
                       } finally {
                           if (removeFile) {
                               LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
                               Files.remove(file);
                           }
                       }
				}
			}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
					.setCacheDuration(Duration.ONE_SECOND));
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:AjaxDownloadBehaviorFromFile.java


示例2: createWriter

import org.apache.wicket.util.file.File; //导入依赖的package包/类
private Writer createWriter(String fileName) throws IOException {
    //todo improve!!!!!!!

    MidpointConfiguration config = getMidpointConfiguration();
    File exportFolder = new File(config.getMidpointHome() + "/export/");
    File file = new File(exportFolder, fileName);
    try {
        if (!exportFolder.exists() || !exportFolder.isDirectory()) {
            exportFolder.mkdir();
        }

        file.createNewFile();
    } catch (Exception ex) {
        error(getString("PageAccounts.exportFileDoesntExist", file.getAbsolutePath()));
        throw ex;
    }

    return new OutputStreamWriter(new FileOutputStream(file), "utf-8");
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:PageAccounts.java


示例3: clearExportPerformed

import org.apache.wicket.util.file.File; //导入依赖的package包/类
private void clearExportPerformed(AjaxRequestTarget target) {
    try {
        MidpointConfiguration config = getMidpointConfiguration();
        File exportFolder = new File(config.getMidpointHome() + "/export");
        java.io.File[] files = exportFolder.listFiles();
        if (files == null) {
            return;
        }

        for (java.io.File file : files) {
            file.delete();
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete export files", ex);
        error("Couldn't delete export files, reason: " + ex.getMessage());
    }

    filesModel.reset();
    success(getString("PageAccounts.message.success.clearExport"));
    target.add(getFeedbackPanel(), get(createComponentPath(ID_FORM_ACCOUNT, ID_FILES_CONTAINER)));
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:PageAccounts.java


示例4: createWriter

import org.apache.wicket.util.file.File; //导入依赖的package包/类
private Writer createWriter(File file) throws IOException {
    OutputStream stream;
    if (isUseZip()) {
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
        String fileName = file.getName();
        if (StringUtils.isNotEmpty(file.getExtension())) {
            fileName = fileName.replaceAll(file.getExtension() + "$", "xml");
        }
        ZipEntry entry = new ZipEntry(fileName);
        out.putNextEntry(entry);
        stream = out;
    } else {
        stream = new FileOutputStream(file);
    }

    return new OutputStreamWriter(stream);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:18,代码来源:PageDebugDownloadBehaviour.java


示例5: createXmlFile

import org.apache.wicket.util.file.File; //导入依赖的package包/类
/**
	 * Create a xml file containing the quality model.
	 * @param model QModel
	 * @return File
	 * @throws JAXBException exception
	 */
//	 * @throws IOException exception
//	public File createXmlFile(QModel model) throws JAXBException, IOException {
	public File createXmlFile(QModel model) throws JAXBException {
			
		file = new File(model.getName()+".xml");
		JAXBContext context = JAXBContext.newInstance(QModel.class);
		Marshaller m = context.createMarshaller();
		m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		//m.marshal(model, System.out);

		// Write to File
		m.marshal(model, file);

		return file;	
	}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:22,代码来源:QModelXmlWriter.java


示例6: createJsonFile

import org.apache.wicket.util.file.File; //导入依赖的package包/类
/**
 * Create a json file containing the quality model received.
 * @param p quality model to parse
 * @return json file
 * @throws IOException exception
 */
public File createJsonFile(QModel p) throws IOException {

	ObjectMapper mapper = new ObjectMapper();
	mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
	mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
	mapper.configure(SerializationConfig.Feature.AUTO_DETECT_GETTERS, true);

	mapper.enable(SerializationConfig.Feature.INDENT_OUTPUT);

	file =  new File(p.getName()+".json");
	// write JSON to a file
	mapper.writeValue(file, p);

	return file;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:22,代码来源:QModelJsonWriter.java


示例7: parseFile

import org.apache.wicket.util.file.File; //导入依赖的package包/类
/**
 * Parse file received to generate an instance of quality model.
 * @param file containing the model in json format
 * @return QModel imported
 * @throws IOException 
 * @throws JsonMappingException 
 * @throws JsonParseException 
 */
public static Project parseFile(File file) throws JsonParseException, JsonMappingException, IOException{
	
	Project proj;
       
       ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS,true);
	mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
	mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
	mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);
	
	proj = mapper.readValue(file, Project.class);
       
	return proj;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:24,代码来源:QProjectJsonParser.java


示例8: parseFile

import org.apache.wicket.util.file.File; //导入依赖的package包/类
/**
 * Parse file received to generate an instance of quality model.
 * @param file containing the model in json format
 * @return QModel imported
 * @throws IOException 
 * @throws JsonMappingException 
 * @throws JsonParseException 
 */
public static QModel parseFile(File file) throws JsonParseException, JsonMappingException, IOException{
	
	QModel qm;
       ObjectMapper mapper = new ObjectMapper();
	mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS,true);
	mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
	mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
	mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);
	
	qm = mapper.readValue(file, QModel.class);
       
	if (qm!=null && (null == qm.getName() || qm.getName().equals("") )) {
		qm.setName("Quality Model Imported"+DateTime.now().toDate());
	}
	return qm;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:26,代码来源:QModelJsonParser.java


示例9: testCreateXmlFile

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Test
public void testCreateXmlFile() {
	
	try {
		File file = writer.createXmlFile(project);
		Assert.assertNotNull(file);
		Assert.assertNotNull(file.getPath());
		Assert.assertTrue(file.isFile());
		logger.info("File created " +file.getAbsolutePath());
		QProjectXmlDomParser.parseFile(file);
		
	} catch (Exception e) {
		e.printStackTrace();
		fail();
	}
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:17,代码来源:QProjectXMLWriterTest.java


示例10: setUp

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Before
public void setUp() {
	
	//get the servlet context
		URL resourceUrl = getClass().getResource("/files/");

	try {
		Path resourcePath = Paths.get(resourceUrl.toURI());
		xmlFile = new File(resourcePath.toString()+"/qmodel.xml");
		xmlFileNM = new File(resourcePath.toString()+"/qmodel_nometric.xml");
		xmlFileNI = new File(resourcePath.toString()+"/qmodel_noindicator.xml");
		xmlFileNO = new File(resourcePath.toString()+"/qmodel_noobjective.xml");
		//xmlFileMand = new File(resourcePath.toString()+"/qmodel_mandatoryfields.xml");
		jsonFile = new File(resourcePath.toString()+"/qmodel.json");
		
	} catch (URISyntaxException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:21,代码来源:QModelParserTest.java


示例11: testParseFileQModelEmptyNameJSON

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Test
public void testParseFileQModelEmptyNameJSON() {
	logger.info("testParseFileQModelEmptyNameJSON start");
		try {
			
			
			String jsonToImport = "{\"@class\" : \"eu.uqasar.model.qmtree.QModel\",\"companyId\" : 173, \"description\" : \"Quality Model pre-loaded\", \"name\" : \"\", \"nodeKey\" : \"Quality Model A, U-QASAR\"}";
			
			File fl = new File("xmlToImport.json");
			fl.createNewFile();
			fl.setWritable(true);
			fl.write(jsonToImport);
			
			qm = QModelJsonParser.parseFile(fl);
			Assert.assertNotNull(qm);
			Assert.assertNotNull(qm.getName());
			Assert.assertTrue(qm.getName().contains("Quality Model Imported"));
			fl.delete();
		} catch (IOException e) {
			e.printStackTrace();
			Assert.assertTrue(false);
		}
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:24,代码来源:QModelParserTest.java


示例12: setUp

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Before
public void setUp() {

	//get the servlet context
	URL resourceUrl = getClass().getResource("/files/");

	try {
		Path resourcePath = Paths.get(resourceUrl.toURI());
		xmlFile = new File(resourcePath.toString()+"/project.xml");
		jsonFile = new File(resourcePath.toString()+"/project.json");

	} catch (URISyntaxException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:17,代码来源:ProjectParserTest.java


示例13: onRequest

import org.apache.wicket.util.file.File; //导入依赖的package包/类
public void onRequest() {
	final File file = initFile();
	IResourceStream resourceStream = new FileResourceStream(new File(file));
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
			new ResourceStreamRequestHandler(resourceStream) {

                   @Override
				public void respond(IRequestCycle requestCycle) {
                       try {
					    super.respond(requestCycle);
                       } finally {
                           if (removeFile) {
                               LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
                               Files.remove(file);
                           }
                       }
				}
			}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
					.setCacheDuration(Duration.ONE_SECOND));
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:21,代码来源:AjaxDownloadBehaviorFromFile.java


示例14: getImageFiles

import org.apache.wicket.util.file.File; //导入依赖的package包/类
public static Set<String> getImageFiles(String packageName) {
  Pattern pattern = Pattern.compile(".*\\.(png|gif|jpg|jpeg|jp2)");
  Set<String> resources = new Reflections(packageName, new ResourcesScanner())
      .getResources(pattern);
  Set<String> filteredResources = new HashSet<String>();
  Map<String, Boolean> resMap = new ConcurrentHashMap<String, Boolean>();
  for (String res : resources) {
    String resName = new File(res).getName();
    if (!resMap.containsKey(resName)) {
      resMap.put(resName, true);
      filteredResources.add(resName);
    }
  }

  return filteredResources;
}
 
开发者ID:apache,项目名称:oodt,代码行数:17,代码来源:Workbench.java


示例15: filterBenchResources

import org.apache.wicket.util.file.File; //导入依赖的package包/类
private Set<String> filterBenchResources(Set<String> bench,
    Set<String> local, String localPrefix) {
  if (local == null || (local.size() == 0)) {
    return bench;
  }
  if (bench == null || (bench.size() == 0)) {
    return bench;
  }
  Set<String> filtered = new HashSet<String>();
  for (String bResource : bench) {
    String localName = new File(bResource).getName();
    String compare = localPrefix + localName;
    if (!local.contains(compare)) {
      filtered.add(bResource);
    } else {
      LOG.log(Level.INFO, "Filtered conflicting bench resource: ["
          + bResource + "]");
    }

  }
  return filtered;
}
 
开发者ID:apache,项目名称:oodt,代码行数:23,代码来源:CurationApp.java


示例16: downloadPerformed

import org.apache.wicket.util.file.File; //导入依赖的package包/类
private void downloadPerformed(AjaxRequestTarget target, String fileName,
                               AjaxDownloadBehaviorFromFile downloadBehavior) {
    MidpointConfiguration config = getMidpointConfiguration();
    downloadFile = new File(config.getMidpointHome() + "/export/" + fileName);

    downloadBehavior.initiate(target);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:8,代码来源:PageAccounts.java


示例17: makeZipLogStream

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Nonnull
private ResourceStreamResource makeZipLogStream(IModel<URI> logPath) {
    return new ResourceStreamResource() {
        @Override
        protected IResourceStream getResourceStream() {
            try {
                return new FileResourceStream(new File(makeZip(logPath)));
            } catch (IOException ex) {
                getLogger().error(ex.getMessage(), ex);
            }
            return null;
        }
    };
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:15,代码来源:LogPanel.java


示例18: makeZip

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Nonnull
private java.io.File makeZip(IModel<URI> logUriModel) throws IOException {
    byte[]       buffer  = new byte[1024];
    Path         logPath = Paths.get(logUriModel.getObject());
    java.io.File zip     = File.createTempFile("log", ".zip");
    try (FileOutputStream fos = new FileOutputStream(zip)) {
        makeZip(buffer, logPath, fos);
    }
    return zip;
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:11,代码来源:LogPanel.java


示例19: getImageData

import org.apache.wicket.util.file.File; //导入依赖的package包/类
@Override
protected byte[] getImageData(Attributes attributes) {
    InputStream inputStream = null;
    try {
        File file = new File(artifactoryHome.getLogoDir(), "logo");
        inputStream = file.inputStream();
        return IOUtils.toByteArray(inputStream);
    } catch (IOException e) {
        throw new RuntimeException("Can't read image file", e);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:14,代码来源:LogoResource.java


示例20: parse

import org.apache.wicket.util.file.File; //导入依赖的package包/类
/**
 * Method to invoke parser xml instance.
 *
 * @Param upload File uploaded ready to parse
 * @return QModel created
 * @throws IOException 
 * @throws JAXBException
 * @throws uQasarException
 */
private QModel parse(FileUpload upload, boolean xml) throws IOException, JAXBException, uQasarException {

	QModel qmodel;
	File newFile = new File(upload.getClientFileName());
	if (newFile.exists()) {
		newFile.delete();
	}

	newFile.createNewFile();
	upload.writeTo(newFile);

	//Parse file and save info
	if (xml) {
		qmodel = QModelXmlDomParser.parseFile(newFile);
	} else {
		qmodel = QModelJsonParser.parseFile(newFile);
	}
	
	List<String> nodeKeyList = qmodelService.getAllNodeKeys();
	
		
	if (Collections.frequency(nodeKeyList, qmodel.getNodeKey()) > 0){
		throw new uQasarException("nodeKey");
	}
	
	newFile.delete();
	return qmodel;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:38,代码来源:QModelImportPage.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParserEditStatus类代码示例发布时间:2022-05-22
下一篇:
Java InvalidDependencyVersionException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap