Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IO Performance

 
Steve Grant
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir,
I am using BufferedOutptStream class to write byte array to a file. Is there any other way to write to the file in a more effecient way in java
. i have my own class called VFSIOService which has the methods addFile and copyFile which are responsible for writing and copying. This class is called by a stateless session ejb VFSFacade. Many users will be uploading their files by calling addFile method on the EJB and also copy their files from source to destination.
The addFile method receives a byte array . Here I am using BufferedOutputStream to write this byte array to the file on hard disk. Is this right approach or is there any other approach which could improve the performance. Following is the sample code of addFile:
addFile(FileTO fileTO) throws Exception
{
BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream("c:/tmp.txt"));
byte b [] = fileTO.getFileBytes();
out.write(b);
out.close();
}
Similarly I am using BuffereInputStream n OutputStream for copying a file from source to destination. My project will be on linux system and so i was thinking about using Runtime.exec method to call linux cp (copy) command which will be resposible for copying the file from source to destination. I thought of this bcuz this will be much faster than using BufferedInputStream n OutputStream . Is there any harm of using above approach.
thx & rgds
Siddharth K
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic