resources

Managing resources in a Python project

浪子不回头ぞ 提交于 2020-01-09 12:24:28
问题 I have a Python project in which I am using many non-code files. Currently these are all images, but I might use other kinds of files in the future. What would be a good scheme for storing and referencing these files? I considered just making a folder "resources" in the main directory, but there is a problem; Some images are used from within sub-packages of my project. Storing these images that way would lead to coupling, which is a disadvantage. Also, I need a way to access these files which

Read directory inside JAR with InputStreamReader

孤人 提交于 2020-01-09 10:28:28
问题 So, this question has been asked a million times i believed and I've been reading them for a couple of hours and trying several options given by some people but none of them work for me. I want to list all the files inside a directory inside the application's JAR, so in IDE this works: File f = new File(this.getClass().getResource("/resources/").getPath()); for(String s : f.list){ System.out.println(s); } That gives me all the files inside the directory. Now, i've tried this also: InputStream

详解Android系统如何找到最匹配的资源文件的(译)

梦想的初衷 提交于 2020-01-07 12:36:32
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 当你需要一个资源文件时, Android 系统会在运行时根据当前设备的配置信息从你提供的资源中选择一个文件。为了呈现出 Android 系统是如何选择一个资源文件的这个流程,假定下面的每个 drawable 目录包含了相同的图片元素的不同像素版本: drawable/ drawable-en/ drawable-fr-rCA/ drawable-en-port/ drawable-en-notouch-12key/ drawable-port-ldpi/ drawable-port-notouch-12key/ 同时,假定设备的配置信息如下 : Locale = en-GB Screen orientation = port Screen pixel density = hdpi Touchscreen type = notouch Primary text input method = 12key 通过比较设备的配置信息和可用的资源文件, Android 系统从目录 drawable-en-port 中选择了图片资源。 系统选择出最佳匹配资源文件的算法思路如下: 1. 首先排除那些与设备的配置信息相矛盾的资源文件。 drawable-fr-rCA/ 目录被排除掉 , 因为它跟设备的信息 Locale : en

(Java) Good Libraries and What they are [closed]

蹲街弑〆低调 提交于 2020-01-07 09:35:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Lets compile a list of 3rd party java libraries that we like and/or find useful. I will post my choices as a reply 回答1: Google Collections Google Collections rules. Gives you predicates, BiMaps, synchronization wrappers around java.util collections, etc. 回答2: Lucene "Apache Lucene is a high-performance, full

(Java) Good Libraries and What they are [closed]

99封情书 提交于 2020-01-07 09:34:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Lets compile a list of 3rd party java libraries that we like and/or find useful. I will post my choices as a reply 回答1: Google Collections Google Collections rules. Gives you predicates, BiMaps, synchronization wrappers around java.util collections, etc. 回答2: Lucene "Apache Lucene is a high-performance, full

(Java) Good Libraries and What they are [closed]

一个人想着一个人 提交于 2020-01-07 09:32:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Lets compile a list of 3rd party java libraries that we like and/or find useful. I will post my choices as a reply 回答1: Google Collections Google Collections rules. Gives you predicates, BiMaps, synchronization wrappers around java.util collections, etc. 回答2: Lucene "Apache Lucene is a high-performance, full

Java WebApp: Loading resource from .jar located in WEB-INF

和自甴很熟 提交于 2020-01-07 05:05:13
问题 There are a lot of similar questions, but, probably, mine is a little bit different: What is the right way to load resource from inside of .jar file located in WEB-INF/lib folder (if I know the jar file name and the name of the class it resource belongs to), while Web Application is running? Should I use getServletContext().getResourceAsStream(?) for this purpose or the <name-of-known-class>.getResourseAsStream(?) , and what path do I need to specify there? So, the structure is: /WEB-INF

Simple way to use a jar as a resource archive

与世无争的帅哥 提交于 2020-01-07 03:10:23
问题 So, I'm working on a Java application and I'd like to package resources into jar files to make them more portable. These jar files would be separate from the application and would only contain assets (images, sounds, save files, etc). What's the simplest way to access arbitrary resources from inside a jar file like this? I've looked around a bit, but haven't been able to find any simple tutorials. I know that I can retrieve input streams from a Jar file with a ClassLoader but how do I get a

How to update arrays in res/values/array.xml by code?

怎甘沉沦 提交于 2020-01-06 21:03:32
问题 I can use Resources res=this.getResources(); arr1=res.getStringArray(R.array.one); to get the array and changed some of its values, Then how can I save the new values back to the file of res/values/array.xml ? 回答1: You cannot "save the new values". Resources are read-only at runtime. 来源: https://stackoverflow.com/questions/7227549/how-to-update-arrays-in-res-values-array-xml-by-code

How to update arrays in res/values/array.xml by code?

空扰寡人 提交于 2020-01-06 21:01:02
问题 I can use Resources res=this.getResources(); arr1=res.getStringArray(R.array.one); to get the array and changed some of its values, Then how can I save the new values back to the file of res/values/array.xml ? 回答1: You cannot "save the new values". Resources are read-only at runtime. 来源: https://stackoverflow.com/questions/7227549/how-to-update-arrays-in-res-values-array-xml-by-code