/*

* Created on Aug 10, 2004

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

package cv_classification;

import java.io.IOException;

import java.io.RandomAccessFile;

/**

* @author tts

*

* To change the template for this generated type comment go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

public class test1 {

public static void main(String[] args) {


String line="";

int iCount=0;

int iFile=0;


RandomAccessFile rf_small=null;

RandomAccessFile rf_Large=null;


try{

rf_Large = new RandomAccessFile("","r");

System.out.println("start" +rf_Large.readLine() );

while ((line = rf_Large.readLine())!=null){

//System.out.println("Line" + line);

if (iCount % 20 == 0){

iFile++;

String name = "small" + Integer.toString(iFile) + ".txt";


if(rf_small!=null)

rf_small.close();

rf_small = new RandomAccessFile("" + name ,"rw");

}



//System.out.println("Line" + line);

rf_small.writeBytes(line+ "\n");

iCount++;

}



rf_Large.close();

}

catch(IOException ioe){

System.out.println("ioe" );

ioe.printStackTrace();

}

catch(Exception e){

System.out.println("general");

e.printStackTrace();

}


}

}

----- Original Message -----
From: "Shahata, Ash" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 10, 2004 1:09 PM
Subject: Breaking large files into smaller ones


> Hi there,
> I have a large file generated from my legacy system which I want o break
down into smaller one before being passed to my SAP system... does anyone
have any sample code that I can use? I'm after a logic that counts the
number of lines, and ever 200 lines it creates a smaller file.
>
> Thanks
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
>  http://java.sun.com/products/jsp
>  http://archives.java.sun.com/jsp-interest.html
>  http://forums.java.sun.com
>  http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to