Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Can a property from a .properties file be made into a usable variable?

20 Aug 2014   #1

Windows 7 Home Premium 64bit
Can a property from a .properties file be made into a usable variable?

I have code to read out lines from .properties, but it just prints it out, because im an idiot and didn't notice till now. So, the question is, can it be made into a variable instead?
current code;
Properties prop = new Properties();
	InputStream input = null;
	try {
		input = new FileInputStream("");
		catch (IOException ex) {ex.printStackTrace();}
			finally {
				if (input != null) {
					try { input.close();} 
						catch (IOException e) {e.printStackTrace();} } }
And anything wrong with the code while I'm asking?

My System SpecsSystem Spec
22 Aug 2014   #2

Windows 7 Ultimate x64

Of course, you're reading and outputting to console immediately, so it can't be of further use. Just assign it to a variable instead. Something like that will do:

int nmbOfCycles = (int)prop.getProperty("CyclesTime");
System.out.println(nmbOfCycles);                         //here it prints the variable with the property value
//further usage of the same property can be done on the variable
Note that I have not tested it, and I don't have really many Java skills, but the idea is that, save to a variable first, then use the variable as many times as you want.
My System SpecsSystem Spec

 Can a property from a .properties file be made into a usable variable?

Thread Tools

Similar help and support threads
Thread Forum
System Properties Not Showing Usable Ram
Windows 7 Professional, SP1, 3GB Physical RAM, 64-bit. System Properties has a label such as this on *OTHER* systems: Installed Memory (RAM): 4.00 GB (3.85GB usable) And you will see this "usable RAM" item in many Windows systems. However, there are some systems where it simply does not...
General Discussion
Need to UNDO a "Folder:Properties:Location:Move" made in error
I am a novice that has run into trouble with Location “ move” tools Folder: Properties: Location: Move).I have tried Googling the issue, but I am not exactly sure what I have done. I am rebuilding my laptop which has a medium size SSD and a 1Tb hard drive running Windows 7 Professional 64.I...
General Discussion
.bat file, batch coding simple variable use
@echo off color C SET IPaddress=0 set /p IPaddress=Please enter the destination Ip Address: color A ping IPaddress pause okay, so i want the IPaddress variable to be used as the ipaddress to be pinged. When i run this, it is ineffective. Can someone teach me as why and how to properly code...
File Open or Choose File dialog hangs application after selection made
Hi. Windows 7 Pro SP1 64 bit Intel i5 CPU @2.67 GHz 8 GB RAM This problem just started recently or I only noticed it in the past week or so. When I'm in any application that launches the File Open dialog, including any browser's "Select File/Browse" button to choose a local file, when I...
General Discussion
CBS.log file: Getting a usable txt file and interpreting the file
First, what does "CBS" mean in cbs.log? Does the cbs.log file show only errors? I create a cbs.log file a lot, so if there are errors, I'd like to correct them. However, my computer seems to be working just fine. sfc /scannow shows everything is OK. I've tried findstr /c:""...
Performance & Maintenance
Need help creating a .bat file moving output into a variable
Hello everyone, I am looking to create a .bat file to automate task that I need to do about a thousand times. I have some experience with .bat files, however I would still consider myself a beginner. I also didn't really see a good forum for something like this so if it need to be moved I...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 09:14.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App