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

Java FileUtils类代码示例

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

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



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

示例1: createOntology

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
/**
    * Creates the file where the OWL ontology will be created.
    *
    * @return void
    */

   public void createOntology(File selectedFile) {
try {
    JenaOWLModel jModel = ProtegeOWL.createJenaOWLModel();
    Collection<MessageError> errors = new ArrayList<>();

    String name = OntologiesUtils.getInstance().getProjectName();
    // Stablish default namespace
    jModel.getNamespaceManager().setDefaultNamespace("http://www.owl-ontologies.com/" + name + ".owl#");

    ArrayList<MObject> contextualEntities = (ArrayList<MObject>) OntologiesUtils.getInstance()
	    .getContextualEntities();

    for (MObject SituationalParameter : contextualEntities) {
	jModel.createOWLNamedClass(SituationalParameter.getName().replaceAll("\\s+", ""));
    }

    jModel.save(selectedFile.toURI(), FileUtils.langXMLAbbrev, errors);

} catch (OntologyLoadException oe) {
    logger.log(Level.SEVERE, oe.getMessage(), oe);
}

   }
 
开发者ID:ualegre,项目名称:ocase,代码行数:30,代码来源:OntologyManager.java


示例2: read

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
final
public void read(Model model, java.lang.String url) 
{
      try {
       	URLConnection conn = new URL(url).openConnection();
       	String encoding = conn.getContentEncoding();
       	if ( encoding == null )
              read(model, new InputStreamReader(conn.getInputStream(), FileUtils.encodingUTF8), url);
       	else
           {
               LoggerFactory.getLogger(this.getClass()).warn("URL content is not UTF-8") ;
               read(model, new InputStreamReader(conn.getInputStream(),encoding), url);
           }
       }
       catch (JenaException e)
       {
           if ( errorHandler == null )
               throw e;
           errorHandler.error(e) ;
       }
       catch (Exception ex)
       {
           if ( errorHandler == null ) throw new JenaException(ex) ;
           errorHandler.error(ex) ;
       }
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:27,代码来源:JenaReaderBase.java


示例3: write

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public void write(Model model, OutputStream out, String base)
     {
    try {
        Writer w;
        try {
            w = new OutputStreamWriter(out, "ascii");
        } catch (UnsupportedEncodingException e) {
            logger.warn( "ASCII is not supported: in NTripleWriter.write", e );
            w = FileUtils.asUTF8(out);
        }
        write(model, w, base);
        w.flush();

    } catch (Exception ioe) {
        errorHandler.error(ioe);
    }
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:18,代码来源:NTripleWriter.java


示例4: asString

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
/**
 * Gets the this request as a single string, or null if something goes wrong
 *
 * @return this Request's inputstream as a String, or null if error
 */
public String asString() {
	try {
		return FileUtils.readWholeFileAsUTF8( getInputStream() );
	}
	catch ( Exception x ) {
		log.warn( x, x );
	}
	return null;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:15,代码来源:CachingServletRequest.java


示例5: initializeReasoner

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
protected void initializeReasoner() throws ConfigurationException {
	if (isConfigurationStale()) {
		// read in a new config model
		setConfigModel(ModelFactory.createDefaultModel());
		getConfigModel().setNsPrefix("", CONFIG_NAMESPACE);
		String configFilename = null;
		try {
			configFilename = getConfigurationFilename();
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
				String syntax = FileUtils.guessLang(configFilename);
				FileInputStream in = new FileInputStream(configFile);
				getConfigModel().read(in, null, syntax);
				timeConfigFileLastModifiedAtInitialization = configFile
						.lastModified();
				in.close();
			} else {
				throw new ConfigurationException("Configuration file '"
						+ configFilename + "' not found.");
			}
		} catch (IOException e) {
			throw new ConfigurationException(
					"Exception getting configuration from file: "
							+ e.getMessage());
		}
	}
	super.initializeReasoner();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:30,代码来源:ConfigurationManagerForEditing.java


示例6: initializeReasoner

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
protected void initializeReasoner() throws ConfigurationException {
	if (isConfigurationStale()) {
		// read in a new config model
		setConfigModel(ModelFactory.createDefaultModel());
		getConfigModel().setNsPrefix("", CONFIG_NAMESPACE);
		String configFilename = null;
		try {
			configFilename = getConfigurationFilename();
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
				String syntax = FileUtils.guessLang(configFilename);
				FileInputStream in = new FileInputStream(configFile);
				getConfigModel().read(in, null, syntax);
				timeConfigFileLastModifiedAtInitialization = configFile
						.lastModified();
			} else {
				throw new ConfigurationException("Configuration file '"
						+ configFilename + "' not found.");
			}
		} catch (IOException e) {
			throw new ConfigurationException(
					"Exception getting configuration from file: "
							+ e.getMessage());
		}
	}
	super.initializeReasoner();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:29,代码来源:ConfigurationManagerForEditing.java


示例7: checkReader

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
protected void checkReader(Reader r)
{
    if ( r instanceof FileReader )
    {
        FileReader f = (FileReader)r ;
        if ( f.getEncoding().equalsIgnoreCase(FileUtils.encodingUTF8) )
            LoggerFactory.getLogger(this.getClass()).warn("FileReader is not UTF-8") ;
    }
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:10,代码来源:JenaReaderBase.java


示例8: loadURLFile

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
/**
 * Open a file defined by a URL and read all of it into a single string.
 * If the URL fails it will try a plain file name as well.
 */
public static String loadURLFile(String urlStr) throws IOException {
    BufferedReader dataReader = FileUtils.readerFromURL( urlStr );
    StringWriter sw = new StringWriter(1024);
    char buff[] = new char[1024];
    while (dataReader.ready()) {
        int l = dataReader.read(buff);
        if (l <= 0)
            break;
        sw.write(buff, 0, l);
    }
    dataReader.close();
    sw.close();
    return sw.toString();
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:19,代码来源:Util.java


示例9: rulesFromURL

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
/**
 * Answer the list of rules parsed from the given URL.
 * @throws RulesetNotFoundException
 */
public static List<Rule> rulesFromURL( String uri ) {
    try {
        BufferedReader br = FileUtils.asBufferedUTF8( FileManager.get().open(uri) );
        return parseRules( Rule.rulesParserFromReader( br ) );
    }
    catch (WrappedIOException e)
        { throw new RulesetNotFoundException( uri ); }
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:13,代码来源:Rule.java


示例10: readFile

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
/**
 * Reads a JSON file from a location relative to /src/main/resources
 */
public static String readFile(String fileName) {
	try {
		return FileUtils.readWholeFileAsUTF8(
				VocidexIndex.class.getResourceAsStream("/" + fileName));
	} catch (IOException ex) {
		throw new VocidexException(ex);
	}
}
 
开发者ID:cygri,项目名称:vocidex,代码行数:12,代码来源:JSONHelper.java


示例11: getQuery

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
private static Query getQuery(String filename) {
	if (!queryCache.containsKey(filename)) {
		try {
			return QueryFactory.create(FileUtils.readWholeFileAsUTF8(
					SPARQLRunner.class.getResourceAsStream("/queries/" + filename)));
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
	}
	return queryCache.get(filename);
}
 
开发者ID:cygri,项目名称:vocidex,代码行数:12,代码来源:SPARQLRunner.java


示例12: guessContentType

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public static String guessContentType(String fileOrUri){
	if ( fileOrUri == null ) return null ;
	if ( fileOrUri.endsWith(".gz") )
    	fileOrUri = fileOrUri.substring(0, fileOrUri.length()-3) ;
	String ext = FileUtils.getFilenameExt(fileOrUri);
	return fileExtToContentType(ext);
}
 
开发者ID:diachron,项目名称:quality,代码行数:8,代码来源:LinkedDataContent.java


示例13: loadModel

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public static Model loadModel(String filenameOrURL) {
	return loadModel(filenameOrURL, null, FileUtils.guessLang(filenameOrURL, null));
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:4,代码来源:CompatibilityFileManager.java


示例14: execSparQLQuery

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public static String execSparQLQuery(String query) {
		System.out.println("execSPINQuery");
		Model model = getUqModel();

		// Register system functions (such as sp:gt (>))
		SPINModuleRegistry.get().init();

		Query arqQuery = ARQFactory.get().createQuery(model, query);
		ARQ2SPIN arq2SPIN = new ARQ2SPIN(model);
		Select spinQuery = (Select) arq2SPIN.createQuery(arqQuery, null);

		System.out.println("SPIN query in Turtle:");
		model.write(System.out, FileUtils.langTurtle);

		System.out.println("-----");
		String str = spinQuery.toString();
		System.out.println("SPIN query:\n" + str);

		// Now turn it back into a Jena Query
		Query parsedBack = ARQFactory.get().createQuery(spinQuery);
		System.out.println("Jena query:\n" + parsedBack);
		
		com.hp.hpl.jena.query.Query arq = ARQFactory.get().createQuery(spinQuery);
		QueryExecution qexec = ARQFactory.get().createQueryExecution(arq, model);
		QuerySolutionMap arqBindings = new QuerySolutionMap();
		arqBindings.add("predicate", RDFS.label);
		qexec.setInitialBinding(arqBindings); // Pre-assign the arguments
		ResultSet rs = qexec.execSelect();
		
//		System.out.println("#####################################################################");
//		
//		if (rs.hasNext()) {
//			QuerySolution row = rs.next();
//			System.out.println("Row: " +row.toString());
//			RDFNode user = row.get("User");
//			Literal label = row.getLiteral("label");
//			System.out.println(user.toString());
//		}
//		RDFNode object = rs.next().get("object");
//		System.out.println("Label is " + object);


		
		
		
		Collection<User> users = Sparql.exec(getUqModel(), User.class, query);
		
		String usersString = "";
		for (User user : users) {
			System.out.println("User: " +user.toString());
			usersString += user.toString() +"<br/>";
		}

		
		
		System.out.println("execSPINQuery() done.");
		return usersString;
	}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:59,代码来源:UQasarUtil.java


示例15: loadConfigurationFile

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
private void loadConfigurationFile() throws ConfigurationException {
	if (getModelFolderPath() != null) {
		String modelFolderPathname = getModelFolderPath().getAbsolutePath();
		String configFilename;
		try {
			configFilename = getModelFolderPath().getCanonicalPath() + File.separator + CONFIG_FILENAME;
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
	            String syntax = FileUtils.guessLang(configFilename);
	            FileInputStream in = new FileInputStream(configFile);
	            getConfigModel().read( in, null, syntax );
	            if (!getConfigModel().contains(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW))) {
	            	// this statement must be there to find built-ins but seems to disappear from time to time--this is a workaround
	            	getConfigModel().add(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW));
	            }
	            Resource df = getConfigModel().getResource(CONFIG_NAMESPACE + DateFormat);
	            Property dmyp = getConfigModel().getProperty(CONFIG_NAMESPACE + dmyOrder);
	            Statement stmt = getConfigModel().getProperty(df, dmyp);
	            if (stmt != null) {
	            	String val = stmt.getObject().asLiteral().getLexicalForm();
	            	if (val.equals(IConfigurationManager.dmyOrderDMY)) {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(true);
	            	}
	            	else {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(false);
	            	}
	            }
	            in.close();
			}
			else {
				logger.warn("Model folder '" + modelFolderPathname + "' has no configuration file.");
			}
		} catch (IOException e) {
			e.printStackTrace();
			throw new ConfigurationException("Failed to load configuration file", e);
		}
	}
	else if (getModelFolderUrl() != null) {
		getConfigModel().read(getModelFolderUrl() + "/" + CONFIG_FILENAME);
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:43,代码来源:ConfigurationManager.java


示例16: loadConfigurationFile

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
private void loadConfigurationFile() throws ConfigurationException {
	if (getModelFolderPath() != null) {
		String modelFolderPathname = getModelFolderPath().getAbsolutePath();
		String configFilename;
		try {
			configFilename = getModelFolderPath().getCanonicalPath() + File.separator + CONFIG_FILENAME;
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
	            String syntax = FileUtils.guessLang(configFilename);
	            FileInputStream in = new FileInputStream(configFile);
	            getConfigModel().read( in, null, syntax );
	            if (!getConfigModel().contains(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW))) {
	            	// this statement must be there to find built-ins but seems to disappear from time to time--this is a workaround
	            	getConfigModel().add(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW));
	            }
	            Resource df = getConfigModel().getResource(CONFIG_NAMESPACE + DateFormat);
	            Property dmyp = getConfigModel().getProperty(CONFIG_NAMESPACE + dmyOrder);
	            Statement stmt = getConfigModel().getProperty(df, dmyp);
	            if (stmt != null) {
	            	String val = stmt.getObject().asLiteral().getLexicalForm();
	            	if (val.equals(IConfigurationManager.dmyOrderDMY)) {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(true);
	            	}
	            	else {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(false);
	            	}
	            }
			}
			else {
				logger.warn("Model folder '" + modelFolderPathname + "' has no configuration file.");
			}
		} catch (IOException e) {
			e.printStackTrace();
			throw new ConfigurationException("Failed to load configuration file", e);
		}
	}
	else if (getModelFolderUrl() != null) {
		getConfigModel().read(getModelFolderUrl() + "/" + CONFIG_FILENAME);
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:42,代码来源:ConfigurationManager.java


示例17: parse

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public void parse(Graph graph, String baseURI, InputStream in)
{
    Reader reader = FileUtils.asUTF8(in) ;
    parse(graph, baseURI, reader) ;
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:6,代码来源:ParserTurtle.java


示例18: getLanguage

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
protected String getLanguage( Resource root, File fullName )
{
Statement s = getUniqueStatement( root, JA.fileEncoding );
return s == null ? FileUtils.guessLang( fullName.toString() ) : getString( s );
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:6,代码来源:FileModelAssembler.java


示例19: read

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public void read(Model model, InputStream in, String base)
     {
    // N-Triples must be in ASCII, we permit UTF-8.
    read(model, FileUtils.asUTF8(in), base);
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:6,代码来源:NTripleReader.java


示例20: create

import com.hp.hpl.jena.util.FileUtils; //导入依赖的package包/类
public static FileGraph create()
{ return new FileGraph( FileUtils.tempFileName( "anonymousFileGraph", ".rdf" ), true, true ); }
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:3,代码来源:FileGraph.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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