Resource « Development « Java I/O Q&A





1. different WAR files, shared resources    stackoverflow.com

Suppose you have several applications which share the same code and most of the other resources, but have a somewhat different look and feel, some labels change, etc. (think branding). ...

2. War-file deployment with shared resources    stackoverflow.com

Consider the following example structure

- Project
    - www
        - files
            ...

3. Getting IO exception for a missing resource    stackoverflow.com

I am testing my code with a negative test case i.e I have removed one of the keys from the property file. In this case the code is suppose to give ...

4. Howto load a resource from WEB-INF directory of a web archive    stackoverflow.com

I have a web archive with a file placed in the WEB-INF directory. How do I load that file in a java class? I know I can put it in the classes directory ...

5. Copy Resource File to Folder?    stackoverflow.com

I have a need to generate complicated text files from a Java desktop application. I've decided the code would be considerably easier to implement if I could copy a template file and ...

6. Java I/O consumes more CPU resource    stackoverflow.com

I am trying to create 100 files using FileOutputStream/BufferedOutputStream. I can see the CPU utilization is 100% for 5 to 10 sec. The Directory which i am writing is empty. I ...

7. Given a classpath resource, is there a way to get the java.io.File object that has/contains it?    stackoverflow.com

If I have a resource on a classpath, I can both load it as stream fine, and there is even a URL representation of it. Unfortunately some implementations of the Url ...

8. Loading all files in a directory in a Java applet    stackoverflow.com

How would one go about programatically loading all the resource files in a given directory in a JAR file for an applet? The resources will probably change several times over the ...

9. Does Java have an equivalent to .NET resource (.resx) files for localization?    stackoverflow.com

Does Java have an equivalent to .NET resource (.resx) files for localization? In .NET, you can define resources as key-value pairs within a standard XML document. The resource files are named according to ...





10. How do I read a file from a package - something like a resource bundle in Java    stackoverflow.com

I have a words.txt file that I have put in a particular java package and would need to read it from that same location. I do not control the deployment, so ...

11. GetResourceAsStream generates java.io.IOException: Root not accessible    stackoverflow.com

InputStream is = this.getClass().getResourceAsStream("/ParseExample/service1.xml"); The code above generates a java.io.IOException: Root is not accessible. This is the structure of the project folder http://www.fileden.com/files/2010/5/28/2872707//projectfiles.JPG How can I properly locate the file? What path should ...

12. Java: Loading resources from the file system    stackoverflow.com

My Project Setup I have the following project setup:

\program.jar  
\images\logo.png
In my code, I reference the image with the relative URL "images/logo.png". Problem If I run this program with the ...

13. How to add reference to .propeties file in .classpath    stackoverflow.com

i've got exception, while running java class from Eclipse:
java.util.MissingResourceException: Can't find bundle for base name dbconfig, locale en_US Seems that my dbconfig.properties file isn't in classpath.

  1. dbconfig.properties located in root of the project.
  2. Eclipse ...

14. How to load StringTemplateGroups from the WEB-INF directory of a web archive    stackoverflow.com

this question is somewhat related to this question: StackOverflow: Howto load a resource from WEB-INF directory of a web archive I want to use StringTemplate and want to load my templates ...

15. how to release resource after delete a file by java    stackoverflow.com

I write code to delete a file, just like:

File logFile = new File(fileName);

deleteSuccess = logFile.delete();
But the Veracode: give me some warning about the resource is not released. I want to know ...

16. How do I reference a resource in Java?    stackoverflow.com

I need to read a file in my code. It physically resides here:

C:\eclipseWorkspace\ProjectA\src\com\company\somePackage\MyFile.txt
I've put it in a source package so that when I create a runnable jar file (Export->Runnable JAR ...





17. How to read a text-file resource into Java unit test?    stackoverflow.com

I have a unit test that needs to work with XML file located in src/test/resources/abc.xml. What is the easiest way just to get the content of the file into String?

18. Get a list of resources from classpath directory    stackoverflow.com

I am looking for a way to get a list of all resource names from a given classpath directory, something like a method List<String> getResourceNames (String directoryName). For example, given a classpath ...

19. Java String externalization key missing    stackoverflow.com

I used the Eclipse string externalisation wizard to extract strings which are then stored in a configuration file. Although when I run it I keep getting an NPE whenever a ...

20. Java - how to access to Excel resource without having a class in same directory?    stackoverflow.com

I am confused how to access to the excel file in my directory. I'm using Netbean 6.9 + GlassFish v3 bundle.

project
  |
  |----web
  |----src
     ...

21. how to create LWUIT res file?    stackoverflow.com

Resources res = Resources.open("/myTheme.res");
UIManager.getInstance().setThemeProps(res.getTheme("myTheme"));
hi I need to open my resource file in LWUIT but how to create a resource file in the first place?

22. Resource file cannot be found    stackoverflow.com

I'm new to Java. I use Eclipse IDE. I have such structure of packages :

Java src:
         -1)org.pdfbox;
       ...

23. Importing directories of resources into a JNLP?    stackoverflow.com

Can I import an entire directory of jar files at once, or must I specify each jar individually when creating a JNLP? If the latter, are there any workarounds?

24. can I load resource from classpath if set to any directory?    stackoverflow.com

I want to load a resource with this:

InputStream iStream = Config.class.getResourceAsStream("autopublisherpath.cfg");
So I set the CLASSPATH to make it work. This is my dir hierarchy:
- autopublisher
     .classes
  ...

25. Get path of a file from a subdirectory of a directory in CLASSPATH    stackoverflow.com

Given the following directory structure:

working-directory
   subfolder1
      file1.wav
      file2.wav
      file3.wav
   subfolder2
   ...

26. How to find unclosed I/O resources in Java?    stackoverflow.com

Many I/O resources in Java such as InputStream and OutputStream need to be closed when they are finished with, as discussed here. How can I search my project for places ...

27. Java - where to store extra resources files    stackoverflow.com

My code require one PNG file. Where should I put it ? I saw some people put them along with .java, then use getClassLoader().getResourceAsStream. Personally, I feel it is not ...

28. In Java, how can I construct a File from a resource?    stackoverflow.com

File takes String and URI in its constructors. getClass().getResource(...) returns URL and getResourceAsStream(...) returns InputStream. Is there a way to construct a File from a resource?

29. Are there any problems with creating large static resource files?    stackoverflow.com

Is it acceptable to create large static resource files? For example:

public class Resources {
    public static String STRING1 = "xxx";
    public static String STRING2 = ...

30. using resource files in a relocatable fashion - HELP    bytes.com

P: 14 dorito I am building an app within NetBeans and I am trying to make my use of resource files relocatable, so when I run my app on a different ...

32. Need java.io Learning Resources    coderanch.com

I'm looking for the best books/online tutorials for java io. I'm preparing to get a hight score for scjp, but that's not all I want. I don't want to just get instant knowledge --I want to learn how to really use the io package. I'd like to get a book for this. Stepwise instructions and simple, commented examples that compile work ...

33. resource file - add quotes around param    coderanch.com

I have a resource file (x.properties) that I'm storing all my sql statements in. how do I get single quotes around a parameter in my properties file? properties file: test.sql=SELECT * FROM member WHERE member_name={0} How do I get the above to output this: SELECT * FROM member WHERE member_name='CHRIS' I've tried: test.sql=SELECT * FROM member WHERE member_name='{0}' and : test.sql=SELECT ...

34. How to read a resource file from war file ??    coderanch.com

Originally posted by Javan Li: Hi all, i've developed an application. But when i make it a war file. some error appear. for example: When i try to read a xml file from /WEB-INF/xml/ as follow, it cannot find it: String dir=context.getRealPath("/"); String file=dir + "/WEB-INF/xml/res.xml"; and this code doesn't work. What should i do?? i appreciate if u can help ...

35. Welcome file & resource constrained.    coderanch.com

Hallo folks. I'd like to know whether is possible to constrain a welcome file. More precisely: I constrained the welcome file ( index.jsp ). When type in the URL http:\\myHost:myPort\Webapp\ the resource isn't constrained, when I type the URL http:\\myHost:myPort\Webapp\index.jsp the resource is constrained. I need to constrain the index.jsp and maintain it as welcome file. Can you help me ? ...

36. java.io.Exception: Insufficient system resources exist to complete the requested serv    coderanch.com

HI, I am trying to copy a large number of bytes into a new File. When doing this I get the error java.io.Exception: Insufficient system resources exist to complete the requested service When the file is small I have no problem for the transfer, but when the file is huge I get this error. Here is the chunk of code I ...

38. what is java's equivalent to c/c++ string table resource files    coderanch.com

Can anyone tell me what is java's equivalent to c/c++ string table resource files? I want to write a logfile scanner that takes it's input parameter from either a string file/table. The scanner reads an error string from a file/table, searches through the log file for that error string; if not found, it reads the next error string from the file/table, ...

41. Resource leak    coderanch.com

Hi, We heard about the case where the application will cause resource leakage if we fail to close the resources properly. Existing snippet : try{ // using I/O Stream // closing the resource } catch(IOException e){ //Log the Exception } Assume that there exists a issue(say I/O operations) which prevents the execution of the program to close the resource. Modified snippet ...

42. How to create WAR file with Resource?    coderanch.com

43. Freemarker loading templates from resources    coderanch.com

So I have designed an app that takes user input through a gui and saves it into a file, then seeds a template file with this data and saves a new file... I want to deploy this app for both mac and windows, and of course have hit the filepath wall . i would like to store my templates in the ...

45. Internationalization - Multiple resource bundle files, or one large one    coderanch.com

I am just starting internationalization on a Java application, and am externalizing my Strings into property (resource bundle) files. My question is: what is better, to store all the Strings in one large property file (making it easier to edit, and maintain) or to have a property file for each GUI Widow/Dialog etc. My concern with one large file is that ...

46. save inf to resource file    coderanch.com

47. Resource file loction    coderanch.com

I would like to load resources, but I"m having trouble and keep getting the dreaded "Can't find bundle for base name NNPMResourceBundle, locale en_US" error. I thought I could fix the file location with the following code. The code attempts to load the resource file, and if it doesn't load, writes out a resource file, and then attempts to reload the ...

48. Writing to embedded resource file    forums.oracle.com

I have an application that needs access to an embedded file. For example, the file is Preferences.cfg and contains application settings. I have no problem getting the file and reading its contents, but I can't seem to find a way to write with an OutputStream to the embedded resource. When I try using a URLConnection to establish the stream, an Exception ...

49. Problems creating file. Can't get resource path.    forums.oracle.com

Hey, I'm new to Java with an Actionscript background and I'm using NetBeans IDE. Now this comes with my basic lack of understanding for how Java works but I'm getting confused a lot so if someone could just steer me in the right direction I'd be very grateful. Essentially I'm checking for a config file and if it's not there, I ...

50. Java: Loading Resource Bundle File with UTF-8    forums.oracle.com

It is clearly spelled out in the API docs: The load and store methods load and store properties in a simple line-oriented format specified below. This format uses the ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes ; only a single 'u' character is allowed in an escape sequence. The ...

51. add Resource Files    forums.oracle.com

52. including a resource file in java    forums.oracle.com

hello all, I am new to java and the question I m asking may be quite basic. I have developed an application which is using a .jpg image file. In the code I m accessing the image by only specifying the name of the file (LoadFile("image.jpg")); instead of specifying the whole path to the location of the image file. The intention ...

53. Question on serialization/deserialization of a resource bundle.    forums.oracle.com

Hi all. I have a question regarding the use or error messages that i wish to log on the client side. My question is what happens if these error messages exists on the server side but are called remotely? Which local will get chosen? The one on the server or the one on the client platform?

54. Loading file from resource    forums.oracle.com

55. java.io.FileNotFoundException: class path resource    forums.oracle.com

I have created a spring project and put my application context on the classpath of the jar file that I then use in a web project. (META-INF\context\applicationcontext.xml) I deploy the EAR file to a server and I get the following error: java.io.FileNotFoundException: class path resource [META-INF/context/JNDIConfigLookupBean.xml] cannot be opened because it does not exist I know the file is there and ...

56. IOException: Resource not found - custom class loader needs findResource    forums.oracle.com

I've been attempting to develop test classes using the PowerMock and Mockito mock frameworks I've developed the tests in Eclipse in windows XP (64 bit) and the tests run to completion with passes One of the classes being tested references the joda-time-1.4.jar and this jar contains the resource org/joda/time/tz/data/ZoneInfoMap I then attempted to migrate the development to running the unit tests ...

57. Java Distribution Resource Files    forums.oracle.com

Hi. I am relatively new to java in general. I have a frustrating problem to which I can't seem to find a working solution: I work in NetBeans 6.5. My application manages user profiles and in doing so it generates (renders) picture files (avatars) which it has to save for each user and load again when each user logs in. In ...

58. Does java have a equivalent of C#'s (.NET) Resource,Settings file feature?    forums.oracle.com

C# in .NET have Resource/ settings file which allows you to put images/files etc.. into the resource file and be built into an .exe. basically mean you don't need to have those images/files stored in a file to my understanding. Does java have something like that? because at the moment you have to put images/files (if your using any) into a ...

59. How to compare and edit Resource bundle file using java programe    forums.oracle.com

Hi All I have two resource bundle with key, value and some comments. I need to write a java code to compare both of the values of the keys and if the values are different then i want to replace the second value with the first value. Its a programe which will udpate the second file with the first file values. ...

60. Accessing a Resource File at Runtime    forums.oracle.com

61. Load a file path from a resource bundle file    forums.oracle.com

62. "insufficient existing resources to complete requested service" IO problem?    forums.oracle.com

I do not have any clue now as how this problem happend and how I can solve it. I wonder if placing all 800k documetns in a single folder causes problem? I know that if I try to call File.listFiles() on a folder with too many files that will cause memory problem. But I didnt have this kind of method call ...

63. java.io.IOException: Insufficient system resources    forums.oracle.com

Hi, We are trying to create the Excel files on PROD through java. It works fine on our local PCs as well as on Test servers for files ranges from 1 mb to 12 mb. In Prod it throws the error message (java.io.IOException: Insufficient system resources exist to complete the requested service) for files larger than 6mb only when the destination ...

64. working with .resx file with resource bundle    forums.oracle.com

65. applet within browser not releasing file resource    forums.oracle.com

hi, I have an applet for ftp images upload. run from eclipse IDE (which uses applet viewer) the applet is ok. if i run my applet from browser here is what happens: i upload a file .& leave the browser opened. i then open this same file with gimp or photo-shop & get file in use error. if i close browser ...