The Artima Developer Community
Sponsored Link

Java Answers Forum
slow painting while reading and writing doubles for MB Files

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
kalpana

Posts: 2
Nickname: kalpana
Registered: Feb, 2002

slow painting while reading and writing doubles for MB Files Posted: Mar 18, 2002 9:52 PM
Reply to this message Reply
Advertisement
for 15MB length file i = 7662080
for 50MB length file i = 12414368

Part of Code for writing into file follows like this:
----------------------------------------------------
try{
fos = new FileOutputStream("Angel.txt");
File f = new File("Angel.txt");
if(f.length() >=4)
{
f.delete();
fos = new FileOutputStream("Angel.txt");
}
dos = new DataOutputStream(new BufferedOutputStream(fos,1000000));
int x=0;
double y_last, y_new;
for(int j=0 ;j<i ;j++)
{
---
---
---
if(some condition)
{
y_new = ....;
try{
//previously in vectors
y_last = y_new;
vect.add(new Line2D.Double(x, y_last, x, y_new)_;

dos.writeDouble(y_new);
}catch(Exception e){System.out.println(e);}
}
}
dos.close();
fos.close();
x++;
}catch(Exception excp){System.out.println(excp);}


part of code for reading from file follows like this:
-----------------------------------------------------
public void paint(Graphics g)
{

try{
double y1, y2 =0;
Line2D.Double doub;
raf = new RandomAccessFile("Angel.txt","r");
dis = new DataInputStream(new BufferedInputStream(new FileInputStream(raf.getFD(),1000000)));
raf.seek((rect.x*8));
for (int i = rect.x; (i < (rect.x + rect.width)); i++)
{
g2.setStroke(new BasicStroke(0)); //2
y1 = y2;
y2 =dis.readDouble();
doub=new Line2D.Double(i,y1,i,y2);
g2.draw(doub);
}
dis.close();
raf.close();
}catch(Exception excp){System.out.println(excp);}
}

I tried using Object Streams but NotSerializable Exception is thrown as Line2D.Double objects
are not serialized.

Topic: What advantages to overload procedure and function identifiers? Previous Topic   Next Topic Topic: Parameters in Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use