Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 23rd, 2004, 03:17 PM
Authorized User
Join Date: Nov 2004
Location: , , .
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default Concatenating files modification

What I want to do, is add an extra tag before the beginning & end of the concatenated files. Current code:
public static void concatenate(File[] args, File dest) throws IOException {
    FileChannel in = null, out = null;
    File source;
       long pos = 0;
       long size;
       try {
             out = new FileOutputStream(dest).getChannel();

             for(int i = 0; i < args.length; i++){
                 source = args[i];
            in = new FileInputStream(source).getChannel();

            size = in.size();
            MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, pos, size);
     } finally {
          if (in != null)      in.close();
          if (out != null)     out.close();

eg. want to change it to concatenate(File[] args, File dest, String tag)
where it adds: <tag> to the beginning and </tag> to the end. Could do it using filewriter, but then I'd have to rewrite the rest of the function. I've been trying to copy over a string, but seems to either overwrite info, or have random data as a result. Does anyone know how to use the MappedByteBuffer correctly?

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
concatenating records rashi Access VBA 9 November 6th, 2008 05:07 PM
Concatenating like records pvasudevan SQL Server 2000 35 August 14th, 2008 09:28 AM
Concatenating many XML files srivalli9 XML 4 March 30th, 2006 03:05 AM
concatenating arrays allee_man BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 August 19th, 2005 08:55 AM
Concatenating many XML files srivalli9 J2EE 0 November 12th, 2003 03:14 PM

All times are GMT -4. The time now is 01:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.