How to save object to url
I want to save some objects from my program. I have the url (getClass().getResource("resources/state.ser")) but can't find how to create a writer from a url that can write an object.
Ruskin wrote:
I want to save some objects from my program. I have the url (getClass().getResource("resources/state.ser")) but can't find how to create a writer from a url that can write an object.If the resource is in a Jar you're out of luck. It cannot be written.
The general approach is to..
1) If the resource exists at a known path(a) use that resource path. If not, get the URL from the Jar, read the bytes, and store it at the known path.
2) Gain a File object to the resource on the known path.
3) Get an InputStream to read from the File object.
4) Get an OutputStream to write to the File object.
a) Something like ${user.home}/com/your/resources/state.ser
There are other options that can be used for sand-boxed code. Depending on the contents of the ser (is that a serialised object?) you might write the data to other places than a file.
BTW - these questions are much more easily and better answered if you can put aside what you are trying to do, and instead tell us what you are trying to achieve. An example of the latter is "I want to offer the end user the program ability to save/restore the application state between runs".
Similar Messages
-
How to save object to SQLite?
Hi,
I am confusing with this.
How to save object (instance of class) to SQLite and read the
object back to Flex?
Thanks
MarkSQLite is a relational database, not an object-oriented
database, so you can't just spit an object into it without
translation. You
could serialize it with JSON or XML and store that in a
column, but then you're giving up most of the benefit of a proper
database engine. It's best to flatten the object yourself into the
database structure. How you do that, exactly, depends on your
object structure(s).
So, if you have an object like this:
var foo:Object = { bar: 'qux', bletch: new Date(), farbly: [
42, 69 ] };
you probably need two tables to represent it: a main "foos"
table (a collection of foo objects) and a separate "farblys" table
to hold the array elements. This separation of arrays out into a
table of their own linked to the original table is called
normalization.
Normalization will be covered in any decent tutorial book on
SQL databases. You'll need to get one to best understand how to
utilize SQLite, or anything like it. I got a lot out of
The
Practical SQL Handbook. I doubt that it covers SQLite
specifically. I have an older edition, so I can't check, but the
current edition was released about the same time that SQLite was,
and SQLite took some time to get noticed. The
SQLite Documentation
will fill in the gaps. The main thing to beware of is that SQLite
doesn't support all the advanced things you will read about in a
general SQL book.
If you don't want to mess with all this object-relational
mapping and normalization stuff, and you don't have much data to
store, you might look into Flash Local Stored Objects (LSO), also
called "Flash cookies". The runtime has a default limit of 100 KB
of data per application. The advantage of LSOs is that you can use
them like any other ActionScript object, and Flash handles the
storage details for you. It's great for configuration data and
small bits of user data. -
Hello, I am concerned with how to save a Vector into a file. Can anyone help me ?
[url http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedWriter.html]java.io.BufferedWriter
-
How to save object to a local file.
Hello all.
I need to save an object, i.e. an ABAP program, to a local file and then be able to "import" it into another system.
I am not talking about the lines of codes that can be saved as a local file, but the whole program including screens and so on. Something similar to releasing a transport with object R3TR PROG ZMYPROGRAM to another system, but instead to the local desktop.
Anyone would know if this can be done?
Regards
LandeHi,
Vist the Link for complete Download there are some utility programs.
http://www.dalestech.com
Regards
vijay -
Reference to C# objects in TestStand - how to save and retreive them
I am new to LabView and TestStand.
I want to use 2 .NET objects in those applications
In Labiew, I successfully created the objects, manipulate the functions through VIs and closed the references.
While I could use the VIs for TestStand, I would rather use the DLL directly.
I am able to create both objects in a sequence, but I have problems with the following:
- I don't know how to save the reference to the object after the constructor is run.
- is the object stored in Globlal variables? I tried 'RunState.Engine' but it does not work
- I don't know how to get the reference back in the other steps where I want to reuse the object to invoke a method on.
- Once I can do the above, I need to get it to work in the 'batch' or 'parallel' modes.
I am using successfully the 'RunState.TestSockets.MyIndex' to select my testing resources,
but I am still confuse as where the array of objects would be.
Note that I already set the number of DUT <> 1 and I can create successfully my 2 objects in X instances.
Thanks,
Daniel Coupaldcoupal,
Getting the reference to the object involves specifying that as a return value in one of your parameters when you specify the module for that action. Inside of the parameters table you can also save that return value as a local object reference and then use it later on in the sequence.
Regarding your second question, I'm not sure what the array of objects is that you're referring to but this KB might be of some assistance.
Message Edited by Jon M on 11-01-2006 12:44 PM
Test Engineer - CTA -
Dynamically built query on execution How to save the data in Object Type
Hi,
In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
output of the query in it. Here is the Object Type I have
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
pkid NUMBER,
pkname VARCHAR2(100);
pkcity VARCHAR2(100);
pkcounty VARCHAR2(100)
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
--I initialize my Object Type*
data := new FIRST_RECORDTYPETAB();
FOR some_cursor IN c_get_ids (username)
LOOP
x_context_count := x_context_count + 1;
-- here I build the query dynamically and the same query generated is
sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
-- and now I need to execute the above query but need to store the output
EXECUTE IMMEDIATE sql_query
INTO *<I need to save the out put in the Type I defined>*
END LOOP;
How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
Any help is appreciated.
Thankshai ,
solution for Dynamically built query on execution How to save the data in Object Type.
Step 1:(Object creation)
SQL> ED
Wrote file afiedt.buf
1 Create Or Replace Type contract_details As Object(
2 contract_number Varchar2(15),
3 contrcat_branch Varchar2(15)
4* );
SQL> /
Type created.
Step 2:(table creation with object)
SQL> Create Table contract_dtls(Id Number,contract contract_details)
2 /
Table created.
Step 3:(execution Of procedure to insert the dynamic ouput into object types):
Declare
LV_V_SQL_QUERY Varchar2(4000);
LV_N_CURSOR Integer;
LV_N_EXECUTE_CURSOR Integer;
LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
OV_V_CONTRACT_NUMBER Varchar2(15);
LV_V_CONTRACT_BRANCH Varchar2(15);
Begin
LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
LV_N_CURSOR := Dbms_Sql.open_Cursor;
Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
Loop
Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
End Loop;
Dbms_Sql.close_Cursor (LV_N_CURSOR);
COMMIT;
Exception
When Others Then
Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
End;
step 4:check the values are inseted in the object included table
SELECT * FROM contract_dtls;
Regards
C.karukkuvel -
How can I save passwords for URL's
How can I save passwords for URL's? I just installed 10.6.7 Snow Leopard. I also had to format my HD drive and reinstall my software.
Hi,
From the Safari menu bar click Safari / Preferences then select the Autofill tab. Select the box next to:
User names and passwords.
Navigate to a site you normally log into with the user name and password. Click Yes when prompted. That will save that information to a new keychain for you.
Passwords are actually stored in your Keychain Access application. (Applications/Utilities)
Carolyn -
How to save the instance in standard lead from custom business object
Hi Experts,
I am unable to save the instance(Record) in standard Lead business object from custom business object.
Steps:
created one custom business object with mandatory fields for creating instance in standard lead.
in quick create screen i bind data elements to standard lead business object elements.
issue:
when i click on preview i am getting exception as Arguments not found
can you please tell me that How to save the instance in standard lead from custom business object with step by step .Hi Vijay,
Please refer this link under that mentioned that how to create lead using ABSL code
Web 2 Lead in SAP Cloud for Customer, step by step - Part 1 - myCloudDoor myCloudDoor
Under the "Action-CreateLead.absl" mentioned how to create lead
the above link for convert web 2 lead functionality and under they create lead using web data from ABSL code.
Regards,
Mithun -
How to save a URL address to enable rapid opening later
How to save a URL in the address box and have it displayed on a tool bar for future use (as in Internet Explorer)
hello brucepardy, please refer to [[Bookmarks Toolbar - Display your favorite websites at the top of the Firefox window]]
-
How to save an object with JSTL
I have an object, how to save it with JSTL?
I have this
public class Auto{
private AutoBomba a;
public AutoBomba getA()
return this.a;
public AutoBomba setA(AutoBomba a)
this.a = a;
How can I set the from a JSP page a AutoBomba? The objects name is only for exampleThere is of course the JSTL c:set tag
This relies on the appropriate variables being in JSTL scope.
<jsp:useBean id="auto" class="com.mypackage.Auto" scope="request"/>
<jsp:useBean id="bomba" class = "com.mypackage.AutoBomba"/>
<c:set target="auto" property="a" value="${bomba}"/>Cheers,
evnafets -
How to save a video file which uses the setCodecChain method on its video t
hi! i really need your help please. i got the Code for RotationEffect and i would like to know how to save it to a file instead of playing it simultaneously in a player:
Here is the code: Plz Help me!!! am doing my final year project
import java.awt.*;
import java.awt.event.*;
import javax.media.*;
import javax.media.control.TrackControl;
import javax.media.Format;
import javax.media.format.*;
* Sample program to test the RotationEffect.
public class TestEffect extends Frame implements ControllerListener {
Processor p;
Object waitSync = new Object();
boolean stateTransitionOK = true;
public TestEffect() {
super("Test RotationEffect");
* Given a media locator, create a processor and use that processor
* as a player to playback the media.
* During the processor's Configured state, the RotationEffect is
* inserted into the video track.
* Much of the code is just standard code to present media in JMF.
public boolean open(MediaLocator ml) {
try {
p = Manager.createProcessor(ml);
} catch (Exception e) {
System.err.println("Failed to create a processor from the given url: " + e);
return false;
p.addControllerListener(this);
// Put the Processor into configured state.
p.configure();
if (!waitForState(p.Configured)) {
System.err.println("Failed to configure the processor.");
return false;
// So I can use it as a player.
p.setContentDescriptor(null);
// Obtain the track controls.
TrackControl tc[] = p.getTrackControls();
if (tc == null) {
System.err.println("Failed to obtain track controls from the processor.");
return false;
// Search for the track control for the video track.
TrackControl videoTrack = null;
for (int i = 0; i < tc.length; i++) {
if (tc.getFormat() instanceof VideoFormat) {
videoTrack = tc[i];
break;
if (videoTrack == null) {
System.err.println("The input media does not contain a video track.");
return false;
System.err.println("Video format: " + videoTrack.getFormat());
// Instantiate and set the frame access codec to the data flow path.
try {
Codec codec[] = { new RotationEffect() };
videoTrack.setCodecChain(codec);
} catch (UnsupportedPlugInException e) {
System.err.println("The processor does not support effects.");
// Realize the processor.
p.prefetch();
if (!waitForState(p.Prefetched)) {
System.err.println("Failed to realize the processor.");
return false;
// Display the visual & control component if there's one.
setLayout(new BorderLayout());
Component cc;
Component vc;
if ((vc = p.getVisualComponent()) != null) {
add("Center", vc);
if ((cc = p.getControlPanelComponent()) != null) {
add("South", cc);
// Start the processor.
p.start();
setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
p.close();
System.exit(0);
return true;
public void addNotify() {
super.addNotify();
pack();
* Block until the processor has transitioned to the given state.
* Return false if the transition failed.
boolean waitForState(int state) {
synchronized (waitSync) {
try {
while (p.getState() != state && stateTransitionOK)
waitSync.wait();
} catch (Exception e) {}
return stateTransitionOK;
* Controller Listener.
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof ConfigureCompleteEvent ||
evt instanceof RealizeCompleteEvent ||
evt instanceof PrefetchCompleteEvent) {
synchronized (waitSync) {
stateTransitionOK = true;
waitSync.notifyAll();
} else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
} else if (evt instanceof EndOfMediaEvent) {
p.close();
System.exit(0);
* Main program
public static void main(String [] args) {
if (args.length == 0) {
prUsage();
System.exit(0);
String url = args[0];
if (url.indexOf(":") < 0) {
prUsage();
System.exit(0);
MediaLocator ml;
if ((ml = new MediaLocator(url)) == null) {
System.err.println("Cannot build media locator from: " + url);
System.exit(0);
TestEffect fa = new TestEffect();
if (!fa.open(ml))
System.exit(0);
static void prUsage() {
System.err.println("Usage: java TestEffect <url>");Can you please send me Your codec class and guide me the way you use it .. i am trying to apply some filters on the movie before presenting. Any help would be appreciated.
-
hello,
i m creating a class that has three JList components.
My problem is how to save the each JList items into a seperate logfile(ie. text file).More info required:
What are in the JList? Strings? Custom objects?
Do you know basic file IO?
http://java.sun.com/docs/books/tutorial/essential/io/index.html
What you will need to do is get the model, ilterate over each element, then write that element out. If the element is a string, then that is easy, just create a FileWriter, and write the string, followed by a new line.
If it is a custom object, then the task is harder, and you need to decide how that object should be represented.
If you are after a computer readable view of the model, rather than a human readable, which can easily be read by Java back into a ListModel, then you want to look at XMLEncoder and XMLDecode, or the Serializing Objects tutorial.
http://java.sun.com/docs/books/tutorial/uiswing/components/list.html -
How do I add multiple URL's to a Bookmarks folder?
Safari question: How do I add multiple URL's to a Bookmarks folder?
Ok...
Click the Bookmarks icon left side of the Safari toolbar then select Boomarks in the sidebar.
Locate the folder then try dragging url's to that folder that way.
If that doesn't work, from your Safari menu bar click Bookmarks > Add Bookmark then click the, "Add this page to" pop up menu then select the folder you want to save that url to. -
How to save pdf file in database
Dear All,
my application is forms 6i and database is 8i,requirement is that how to save pdf file in database and users can view through formsI'll apologize up front for the length of this post. I have a few database procedures I created that write a file to a BLOB column in a table as well as retrieve the BLOB from the column after it stored there. I have successfully stored many different types of binary file to the database using these procedures - including PDF files. I have not used these procedures in a Form so I can confirm that they will work, but theoretically they should work. I'm including the code for each procedure in this posting - hence the apology for the long post! :-)
Also, since these procedures reside on the database you will need to use Forms TEXT_IO built-in package to write your file to the server before you can use these procedures to store and retrieve the file from the database.
These procedures reads and writes a binary file to a table called "LOB_TABLE." You will need to modify the procedure to write to your table.
-- Author : Craig J. Butts (CJB)
-- Name : load_file_to_blob.sql
-- : This procedure uses an Oracle Directory called "IN_FILE_LOC". If you
-- already have a directory defined in the database or would prefer to use
-- a different Directory name, make sure you modify line 21 to reflect the
-- new Directory name.
-- ==================================================================================
-- History
-- DATE WHO DESCRIPTION
-- 12/11/07 CJB Created.
CREATE OR REPLACE PROCEDURE load_file_to_blob (p_filename IN VARCHAR2) IS
out_blob BLOB;
in_file BFILE;
blob_length INTEGER;
vErrMsg VARCHAR2(2000);
BEGIN
-- set the in_file
in_file := BFILENAME('IN_FILE_LOC',p_filename);
-- Get the size of the file
dbms_lob.fileopen(in_file, dbms_lob.file_readonly);
blob_length := dbms_lob.getlength(in_file);
dbms_lob.fileclose(in_file);
-- Insert a new Record into the tabel containing the
-- filename specified in P_FILENAME and a LOB_LOCATOR.
-- Return the LOB_LOCATOR and assign it to out_blob.
INSERT INTO lob_table (filename, blobdata)
VALUES (p_filename, EMPTY_BLOB())
RETURNING blobdata INTO out_blob;
-- Load the file into the database as a blob.
dbms_lob.open(in_file, dbms_lob.lob_readonly);
dbms_lob.open(out_blob, dbms_lob.lob_readwrite);
dbms_lob.loadfromfile(out_blob, in_file, blob_length);
-- Close handles to blob and file
dbms_lob.close(out_blob);
dbms_lob.close(in_file);
commit;
-- Confirm insert by querying the database
-- for Lob Length information and output results
blob_length := 0;
BEGIN
SELECT dbms_lob.getlength(blobdata) into blob_length
FROM lob_table
WHERE filename = p_filename;
EXCEPTION WHEN OTHERS THEN
vErrMsg := 'No data Found';
END;
vErrMsg := 'Successfully inserted BLOB '''||p_filename||''' of size '||blob_length||' bytes.';
dbms_output.put_line(vErrMsg);
END;
-- Author : Craig J. Butts (CJB)
-- Name : write_blob_to_file.sql
-- Descrip : This procedure takes a BLOB object from a database table and writes it
-- to the file system
-- ==================================================================================
-- History
-- DATE WHO DESCRIPTION
-- 12/11/07 CJB Created.
CREATE OR REPLACE PROCEDURE write_blob_to_file ( p_filename IN VARCHAR2 ) IS
v_blob BLOB;
blob_length INTEGER;
out_file UTL_FILE.FILE_TYPE;
v_buffer RAW(32767);
chunk_size BINARY_INTEGER := 32767;
blob_position INTEGER := 1;
vErrMsg VARCHAR2(2000);
BEGIN
-- Retrieve the BLOB for reading
BEGIN
SELECT blobdata
INTO v_blob
FROM lob_table
WHERE filename = p_filename;
EXCEPTION WHEN OTHERS THEN
vErrMsg := 'No data found';
END;
-- Retrieve the SIZE of the BLOB
blob_length := DBMS_LOB.GETLENGTH(v_blob);
-- Open a handle to the location where you are going to write the blob
-- Note: The 'WB' parameter means "Write in Byte Mode" and is only
-- available in the UTL_FILE pkg with Oracle 10g or later.
-- USE 'W' instead for pre Oracle 10q databases.
out_file := UTL_FILE.FOPEN('OUT_FILE_LOC',p_filename, 'wb', chunk_size);
-- Write the BLOB to the file in chunks
WHILE blob_position <= blob_length LOOP
IF ( ( blob_position + chunk_size - 1 ) > blob_length ) THEN
chunk_size := blob_length - blob_position + 1;
END IF;
dbms_lob.read(v_blob, chunk_size, blob_position, v_buffer );
UTL_FILE.put_raw ( out_file, v_buffer, TRUE);
blob_position := blob_position + chunk_size;
END LOOP;
END;Hope this helps.
Craig...
-- If my response or the response of another is helpful or answers your question please mark the response accordingly. Thanks! -
How to add a new url link in a view of an existing webdynpro component?
How to add a new url link in a view of an existing webdynpro component?
hi ,
refer SAP online hep :
Implementing Enhancements in a View
http://help.sap.com/erp2005_ehp_04/helpdata/EN/46/233f2189f74f08e10000000a114a6b/frameset.htm
To enhance the layout of the view, you can create new UI elements. This procedure is no different u2013 from a technical viewpoint u2013 from creating UI elements in components themselves. All UI elements created within the enhancement implementation can then be processed as usual.
Enhancements means inserting user developments into SAP development objects at predefined positions.
The Enhancement Framework enables you to add functionality to standard SAP software without actually changing the original repository objects, and to organize these enhancements as effectively as possible.
refernce :
have a look at this article
How to Create Enhancement Implementation in Web Dynpro ABAP
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/700317da-bd79-2c10-368e-8f18bf5d8b81&overridelayout=true
as pointed correctly by Saurav in earlier thread
regards,
amit
Maybe you are looking for
-
I just bought an Iphone 4 from straight talk. My camera does not work. The shutter does not open and when it does open there is a black screen. I am very upset. I have wanted this phone for awhile. I want the issue fixed.
-
Photoshop assets missing when published
I wasn't sure if anyone had any answers for why photoshop assets that I've copied and pasted into iWeb won't show after they are published. These are photos i've stripped from their backgrounds and pasted into my iWeb site. They appear to be there on
-
IPhoto library - missing books
I have a big iPhoto library, about 30.000 photos I have created several books (which I printed with apple). Now I can't open the books any more, it is there, but when I click on the book name, it doesn't do anything, still shows the photos from an e
-
VI of the Day (10/20/2009) - Select
Today it is the "Select" function. A very common task is to select between two values, and this function does that in a tidy little package. And unlike the case structure, we can easily see what both choices are on the BD. What you end up with is
-
How to move titles around in the frame
How to move titles around in the frame