Saving a process/thread into a file
I want to simulate a Object Oriented Database using a Process or a Thread. I need to save and load a the thread quickly and if possible, I would like not to serialize. Is there a way to just dump the Thread status and memory content into a file and Load it back when I load the application? or do I need to serialize all the objects and recreate them every single time?
It's an interesting area of CS research to be able to do this, but unfortunately not possible in Java. Once you start thinking about the fact that, in the internals, all the object references and such are just pointers to blocks of memory, and when you dump the memory to disk, and load it back in... the object data may not be in the same place as it was when you first had it loaded. This makes all the pointers break, etc...
Now, once you start thinking about things like open file handles and network sockets, or thread/process stacks, registers (even in Java, virtual registers) and execution locations... it's kind of mind-boggling that there are people out there smart enough to be working on a way to do it!
Anyways, no there's no way to do it in Java.. you've got to serialize all your objects, and start back from scratch- furthermore, to my knowledge, there's absolutely no way to pick up program execution where it left off (i.e., if you were in the middle of executing a method when you dumped to disk). Could be wrong about that, though...
Sorry I went on like that, hope it was informative at least!
Similar Messages
-
Saving result from query into CSV file
Hi folks,
in our application we're generating pages source using general packages (like htp, owa_util, ...). and in this part I'm a really beginner.
I want to modify source one of our page, I want to add functionality to enable save result from query (cursor) into CSV file, to enable user choose place where generated file will be created and also change file name.
I searched this forum and I found procedure, that could be useful:
procedure p_getcsv is
cursor cur is
select 'a1' col1, 'b1' col2, 'c1' col3 from dual
union select 'a2' col1, 'b2' col2, 'c2' col3 from dual
union select 'a3' col1, 'b3' col2, 'c3' col3 from dual;
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="test.csv"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in EMP
for x in cur
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn(x.col1||','|| x.col2||','||x.col3|| chr(13));
end loop;
end;What peace of code should I add to procedure that is generating web page to enable calling this procedure and whole saving process?
Can anybody help me with this?
Many thanks,
Tomas
Message was edited by:
TomeoHi Marc,
thanks for reply, problem is that I'm not using APEX application, I'm just generating web page code straight using oracle general packages.
But I found this solution (maybe some tunning will be good):
In page where I want to display Download i have
begin
htp.anchor2 (
curl => ... .p_getcsv'||'?term=2005&crn=123,
ctext => 'Download Class List'
HTP.br;
end;
...si I'm calling p_getcsv procedure:
procedure p_getcsv( term IN stvterm.stvterm_code%TYPE DEFAULT NULL,
crn IN sirasgn.sirasgn_crn%TYPE DEFAULT NULL) is
v_length NUMBER;
v_file_name VARCHAR2 (2000);
temp_blob blob;
line RAW(32767);
begin
DBMS_LOB.CREATETEMPORARY(temp_blob, TRUE);
FOR i IN 1..6 LOOP
line := UTL_RAW.CAST_TO_RAW(i||','||term||','||crn||',AAA,BBB,CCC'||chr(10));
DBMS_LOB.WRITEAPPEND(temp_blob, LENGTH(UTL_RAW.CAST_TO_VARCHAR2(line)), line);
END LOOP;
v_file_name := 'ClassList.csv';
v_length := DBMS_LOB.getlength (temp_blob);
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
OWA_UTIL.mime_header (NVL ('csv', 'application/octet'), FALSE);
-- set the size so the browser knows how much to download
HTP.p ('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
HTP.p ( 'Content-Disposition: attachment; filename="'
|| REPLACE (REPLACE (SUBSTR (v_file_name,
INSTR (v_file_name, '/') + 1
CHR (10),
NULL
CHR (13),
NULL
|| '"'
-- close the headers
OWA_UTIL.http_header_close;
-- download the BLOB
WPG_DOCLOAD.download_file (temp_blob);
-- release temporary blob
dbms_lob.freetemporary(temp_blob);
end;Regards,
Tomas -
[IDS3 JAVA] Saving an embed link into a file
Hello,
I have a rectangle that contains a link - this link is embeded, and the source file is not available from the server. Is there a way to save this linked document into a file or to have the array of "byte[]" 5for example) of the data of the linked file ?
I take any other solutions ...My mistake.... the unembed function take a folder as parameter... so I can unembed a file even if the link doesn't exist.
-
Problem in saving the spool list into Excel file.
Hello Friends,
I run a background process for a report, and storing the resulting list into Excel format file. But the result is column values jumbled, it means columns values are not sitting in the right place in excel sheet.
I also tried saving as unconverted text file and then open it using excel still the same result.
Cheers,
SenthilHi,
Use the FM 'EXCEL_OLE_STANDARD_DAT'.
In this FM populate the tables parameter 'fieldnames' to get each cloumn below the heading correctly. -
Convert jsp processed result into a file??
when a JSP file has been processed, it returns HTML codes to browser, so how can i get that pure HTML source code and save it in an other html files.
If you have a good idea, open your JSP file and (in Sun ONE anyways) you can right click and do "Show JSP Code in Servlet" since a JSP is just translated into a servlet anyways (you could alos find the <Your JSP>.java file in your web server's working directory.
Anyways you will see a lot of out.println() statements where out is the response writer. So your options are:
1. Create a FileWriter fwOut and copy all the out.println() statements and paste them as fwOut.println()'s.
2. Create a class (or find one) that mimics the tee functionality in the UX world ie the class myTee opens the respose writer and the FileWriter, then some method (like myTeePrintln()) would take the input as a string and write it to both the response and FileWriter (and flush the streams).
3. http://nitric.com/jnp/source/jnp-src/Tee.java
If helps, I'm hungry for Dukies!
--Thunder -
OS: WinXP sp3
FF: 3.6.3
I have difficulty pasting text into the file name field (prefix only) while saving files. example: File name is Pic123.jpg and I want to rename it ABC123.jpg and I have ABC loaded into the WinXPsp3 clipboard. When I highlight\right-click\delete "Pic" then attempt to paste the ABC, I get either no reaction, or upon multiple paste attempts, the ABC is appended to the end of the file, after the extension, as "Pic123.jpgABC". If I delete this unwanted suffix, or repeat the process several times, eventually I can delete the unwanted portion of the prefix and paste the desired text. Sometimes it works fine first try, but mostly it takes several tries. I'm using Firefox 3.6.3 but the problem existed in whatever previous version I had too. This issue only occurs when using the delete/paste; I can always manually change the name by typing. Thank you for your help.Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
*Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
*https://support.mozilla.org/kb/Safe+Mode
A possible cause is that the server sends a wrong response header.
The server may not comply to RFC 5987 and sends a wrong Content-Disposition:attachment; filename header.
* https://developer.mozilla.org/en/Firefox_8_for_developers#Network -
I have been unsuccessful merging serval pdf files into one file. I select the Sidebar for both pdfs, then drag one pdf on top of the other and Save the Version. When I open the file I think I have saved, it shows only the original pdf. Advice would be appreciated. Thank you.
wouldnt it be easier if you could do something like this?
https://discussions.apple.com/thread/3392535 -
I received a dozen pictures in a few emails and I saved them all into one file in pages. I just copied and pasted. I do not have the originals any longer. Iphoto will not permit me to import the pictures as it does not recognize a .pages file, nor can I simply click and drag from the pages document to iphoto nor from pages to the desktop to iphoto. How can I save each picture I guess back into a jpeg and then import them into iphoto or have i lost them to a pages document forever? This is urgent as I need the pictures made into a book on iphoto for work by Friday!!! Please advise! Thank you.
Greetings,
Locate the Pages document wherever it's located on your computer and click once on it to highlight it.
Go to File > Duplicate to make a backup copy of the file.
Click once again on the file to highlight it.
Go to File > Get Info
In the "Name & Extension" category remove the ".pages" extension and put in ".zip".
Close the info window and double-click the now renamed pages file (zip file now).It will decompress into a folder which contains all the base components including all the images you added. These can be dragged onto the iPhoto icon to import them.
Hope that helps. -
Set Adobe Acrobat XI Pro. When I want to save the file in WORD, EXCEL or esporta file into ... immediately throws an error "save as failed to process this document no file was created".
What's the problem?
Any help in finding a solution is greatly appreciated.
Thank you,Installed AcrobatXI PRO 11.0.09 on seven computers and laptops. Two of them gives an error when you try to save a document in WORD, EXCEL, Power Point, or when exporting to... error: Save failed to process this document. No File was created.
But all good saves in the format of TXT and jpg.
I have uninstalled and restored and re-installed and updated and registry cleaned and removed using the special utility Cleaner Tool for Acrobat, but nothing helps.
On one notebook with Windows 8.1 and Microsoft office 2013, on another laptop with Windows 7 and Microsoft office 2010, the same problem, although there are computers with Windows 7 and Microsoft office 2010 and everything works.
Tell me where to find the problem and how to solve it.
Thank you. -
Saving an integer array into a .txt file
hii, im only a beginner in java, so this is the only code i've learned so far for saving array elements into a file
public static void saveNames(String [] name) throws IOException
FileWriter file = new FileWriter("Example\\names.txt");
BufferedWriter out = new BufferedWriter(file);
int i = 0;
while (i < name.length)
if (name[i] != null)
out.write(name);
out.newLine();
i++;
out.flush();
out.close();
However, this is only used for string arrays; and i can't call the same method for an integer array (because it's not compatible with null)
I don't really understand this code either... since my teacher actually just gave us the code to use, and didn't really explain how it works
I have the same problem for my reading a file code as well --> it's only compatible with string
public static String [] readNames (String [] name) throws IOException
int x = 0;
int counter = 0;
String temp = "asdf";
name = new String [100];
FileReader file = new FileReader("Example\\names.txt");
BufferedReader in = new BufferedReader(file);
int i = 0;
while (i < array.length && temp != null) // while the end of file is not reached
temp = in.readLine();
if (temp != null)
name[i] = temp; // saves temp into the array
else
name[i] = "";
i++;
in.close(); // close the file
return name;
Could someone suggest a way to save elements from an integer array to a file, and read integer elements of that file?
Or if it's possible, replace null with a similar variable (function?), that is suitable for the integer array (i can't use temp != 0 because some of my elements might be 0)
Thanks so much!!!!!because it's not compatible with nullI think it should be okay to just remove the null condition check since there are no null elements in a primitive array when writing.
Use Integer.parseInt() [http://java.sun.com/javase/6/docs/api/java/lang/Integer.html] to convert the String into an Integer when you read it back and use Integer.toString() to be able to write it as a String. -
Problem with data saving into text file
Hi,
The problem I am facing wihile saving the data into text file is that everytime when I am slecting the path from front panel, the data which is being saved is appended with the previous data, i.e. not only in the new text file, the new set of data is saved but also, if there is any previuos run for the program, the corresponding data is also present in that text file.
However, when I change the same 'control'(file path) to 'constant' in the block diagram, and add the file path, there is no such problem. Basically, changing the "File path" from constant in the block diagram to control (so that it is displayed in the front panel) is causing the problem.
Please help!
Thanks
Solved!
Go to Solution.
Attachments:
front panel.JPG 222 KB
Block Diagram.JPG 70 KB
Block diagram with File Path as Constant.JPG 74 KBYour shift register on the For loop is not initialized. It will retain the value of the string from the last time it executed. Initialize that and it should solve your problem.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot -
once image is edited- how do I save it to desktop or a file to later insert it in an illustrator layout? I tried to save it and it saved but it opens into photoshop elements editing page
Right click > Open with and choose the program to open it.
-
Saving characters with ASCII codes (128 - 256) into txt file problem
Hello,
I am saving a query results into a text file (test.txt) with this procedure:
BEGIN
OWA_UTIL.mime_header ('application/octet', FALSE);
HTP.p ('Content-Disposition: attachment; filename="TEST.TXT"');
OWA_UTIL.http_header_close;
for rec in (select sample_text from tmp)
loop
htp.prn ( chr(230) || rec.sample_text || utl_tcp.crlf);
end loop;
-- Send an error code so that the rest of the HTML does not render
HTMLDB_APPLICATION.g_unrecoverable_error := TRUE;
END;
How can I save characters with ascii codes from 128 - 256 into the output file? If I use chr() function, characters are missing in the output file.
Platform: Apex 4.2 on apex.oracle.comHi 1010398,
Some thoughts:
I assume you've counted the characters in the output and/or used a "hex" text editor so you KNOW these characters are not being written. Are they not written at all, or are blanks being substituted or are NULLs being substituted?
I couldn't find much documentation on htp.prn. Though, one place I found
htp.prn (cbuf IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL);Do you suppose it's affected by the character set used?
Howard -
Saving multiples objects into a file
I want to create a single file that has multiples things inside, like pictures (png) and texts. Does someone knows how it will be the structure of the binary file?
I'm programming a draw software like photoshop, where my layers are BufferedImages. Theses bufferedImages must be saved into a file to re-open later and edit.
Please I want just ideas....
thanksIf the objects that you store in your file are fairly independent of each other, one thing that comes
to mind is to make your file a zip file of component files. That way you can use standard tools to examine
it and edit it if you wish.
Another thing to note is that if your file is largely a series of images, some image file formats,
like tiff , jpeg and gif allow you to store sequences of images in one file.
Here's a demo that creates a tiff file holding four images, then reads the file and displays the images.
Stardard software like Kodak's "Imaging Preview" will allow you to flip through the images in the file.
By the way, if you don't have readers/writers for format tiff, you can get them here.
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.imageio.*;
import javax.imageio.stream.*;
import javax.swing.*;
public class IOExample {
public static void main(String[] args) throws IOException {
String urlPrefix = "http://www3.us.porsche.com/english/usa/carreragt/modelinformation/experience/desktop/bilder/icon";
String urlSuffix = "_800x600.jpg";
int SIZE = 4;
BufferedImage[] images = new BufferedImage[SIZE];
for(int i=1; i<=SIZE; ++i)
images[i-1] = ImageIO.read(new URL(urlPrefix + i + urlSuffix));
File file = new File("test.tiff");
file.delete();
int count = writeImages(images, file);
if (count < SIZE)
throw new IOException("Only " + count + " images written");
images = null;
images = readImages(file);
if (images.length < SIZE)
throw new IOException("Only " + images.length + " images read");
display(images);
public static void display(BufferedImage[] images) {
JFrame f = new JFrame("IOExample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel(new GridLayout(0,1));
for(int j=0; j<images.length; ++j) {
JLabel label = new JLabel(new ImageIcon(images[j]));
label.setBorder(BorderFactory.createEtchedBorder());
p.add(label);
f.getContentPane().add(new JScrollPane(p));
f.setSize(400,300);
f.setLocationRelativeTo(null);
f.setVisible(true);
//suffix is "jpeg", "gif", "png", etc... according to your service providers
public static ImageWriter getWriter(String suffix) throws IOException {
Iterator writers = ImageIO.getImageWritersBySuffix(suffix);
if (!writers.hasNext())
throw new IOException("no writers for suffix " + suffix);
return (ImageWriter) writers.next();
public static ImageReader getReader(String suffix) throws IOException {
Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
if (!readers.hasNext())
throw new IOException("no reader for suffix " + suffix);
return (ImageReader) readers.next();
public static int writeImages(BufferedImage[] sources, File destination) throws IOException {
if (sources.length == 0) {
System.out.println("Sources is empty!");
return 0;
} else {
ImageWriter writer = getWriter(getSuffix(destination));
ImageOutputStream out = ImageIO.createImageOutputStream(destination);
writer.setOutput(out);
writer.prepareWriteSequence(null);
for(int i=0; i<sources.length; ++i)
writer.writeToSequence(new IIOImage(sources, null, null), null);
writer.endWriteSequence();
return sources.length;
public static BufferedImage[] readImages(File source) throws IOException {
ImageReader reader = getReader(getSuffix(source));
ImageInputStream in = ImageIO.createImageInputStream(source);
reader.setInput(in);
ArrayList images = new ArrayList();
GraphicsConfiguration gc = getDefaultConfiguration();
try {
for(int j=0; true; ++j)
images.add(toCompatibleImage(reader.read(j), gc));
} catch(IndexOutOfBoundsException e) {
return (BufferedImage[]) images.toArray(new BufferedImage[images.size()]);
public static String getSuffix(File file) throws IOException {
String filename = file.getName();
int index = filename.lastIndexOf('.');
if (index == -1)
throw new IOException("No suffix given for file " + file);
return filename.substring(1+index);
//make compatible with gc for faster rendering
public static BufferedImage toCompatibleImage(BufferedImage image, GraphicsConfiguration gc) {
int w = image.getWidth(), h = image.getHeight();
int transparency = image.getColorModel().getTransparency();
BufferedImage result = gc.createCompatibleImage(w, h, transparency);
Graphics2D g = result.createGraphics();
g.drawRenderedImage(image, null);
g.dispose();
return result;
public static GraphicsConfiguration getDefaultConfiguration() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.getDefaultConfiguration(); -
Is there anyway to import my file title like img_001 into my file info so it will show up in my metadata?
you can re-number files as you import
you may need to a test of a few un-important files
click the re-name file panel >>tick>>template>>click on arrows>>edit and that will take you the customize panel
add image name like "img"
then add numbering I have only used the first one (import)
make sure you add two "00" so they stay in order
should look like img-001
bugga of a number tool imo; bridge is easier/better
you could also rename in windows or bridge or other programs before importing BUT ONLY IF THE FILES HAVE NOT BEEN IN LR ALREADY. Sorry to yell thats important as you most likely know
Yell if that doesn't make sense
Maybe you are looking for
-
2007 MacBook Pro Screen becomes distorted and Computer becomes unresponsive
Hi, I am wondering if anyone else has experienced this. This is hard to explain with words alone, but I will try: I'll be using my 2007 MacBook Pro with no problems, when all of a sudden the screen will start to flicker and the display will become di
-
ALERTS: Is it possible to create a new container Variable in Existing alert
Hi PI Experts, I have a existing alert ZTEST defined in ALRTCATDEF. Now I want to create a new container variable PONUM to ZTEST in a UDF and populate it with a value coming in the payload. I have defined an alert rule for this alert and this alert w
-
Can any body guide me how to check stock transfer one plant to another plant i have two plants 1001 and 1002 i send semi finished material 1001 plant to 1002 plant my query is i activate 08 inspection type but it is appear in inspection lot in 1001
-
Front Image Button Missing?
Re: PS - Creating a Triptych in Photoshop | The Complete Picture with Julieanne Kost | Adobe TV I have looked in Photoshop CS6 and Photoshop CC and can't find the 'Front Image' button. How do I bring it up?
-
I got this new job, where they use old G4s with Jaguar (10.2). I try to connect to a server, and the icon mounts on my desktop, but when I try to open it, it relaunches Finder. If I were to try to open a document from within an application (InDesign,