LISTSERV mailing list manager LISTSERV 16.5

Help for KPIX-BEAMTEST-SOFTWARE Archives


KPIX-BEAMTEST-SOFTWARE Archives

KPIX-BEAMTEST-SOFTWARE Archives


KPIX-BEAMTEST-SOFTWARE@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

KPIX-BEAMTEST-SOFTWARE Home

KPIX-BEAMTEST-SOFTWARE Home

KPIX-BEAMTEST-SOFTWARE  July 2013

KPIX-BEAMTEST-SOFTWARE July 2013

Subject:

Re: storing data in a .class?

From:

"McCormick, Jeremy I." <[log in to unmask]>

Reply-To:

Discussion of software development for the KPiX beamtest <[log in to unmask]>

Date:

Thu, 11 Jul 2013 15:38:12 -0700

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (58 lines)

Hi,

I suggest putting the geometry data into your jar file as a resource to eliminate any dependency on the local file system.

The files need to be packaged correctly into the jar, which is a matter of configuring the resources section of your Maven project correctly (assuming you use Maven).

Then you may get the resource at runtime using a call similar to this:

InputStream is = getClass().getResourceAsStream("/path/to/geom/data.txt");

You need to replace the above string with the actual location in your jar.  (Jar files are technically just zip files, so they have an internal directory hierarchy containing class files and resources.)

The InputStream can then be easily parsed as text.  

Here are a bunch of solutions for doing this:

http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string

But the geometry could potentially change across runs, so this suggests to me that eventually a proper conditions system should be used like we have in lcsim, which would fetch the proper data based on run numbers and/or time stamps.  

But barring that you can load data directly from the jar as I've described.  It should work fine.

--Jeremy

-----Original Message-----
From: [log in to unmask] [mailto:[log in to unmask]] On Behalf Of Dylan Mead
Sent: Thursday, July 11, 2013 3:09 PM
To: Graf, Norman A.; kpix-beamtest-software
Subject: [KPIX-BEAMTEST-SOFTWARE] storing data in a .class?

Hi Norman,

I've been digging around online for a solution but you can only do so much when you're not sure how to ask the right question. Hopefully you can help.

Here is the problem. Our display class has a statically defined path to a text file that holds all of the geometry information that is used for drawing the detector. This screws up portability because anytime I go to use it on a different machine I have to edit the path in the KpixHepRepConverter.java to the new location of geometry.txt, recompile, and put geometry.txt in the right location on the other machine.

I would like to have a class that I can put in the package with the display. Then in the display class I could have a line like

double[][] sensorGeometry = GeometryClass.getGeometry();

Is this doable?

-Dylan

________________________________


Use REPLY-ALL to reply to list

To unsubscribe from the KPIX-BEAMTEST-SOFTWARE list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=KPIX-BEAMTEST-SOFTWARE&A=1 

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the KPIX-BEAMTEST-SOFTWARE list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=KPIX-BEAMTEST-SOFTWARE&A=1

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

May 2014
April 2014
March 2014
November 2013
September 2013
August 2013
July 2013
June 2013
May 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use