The Artima Developer Community
Sponsored Link

Java Answers Forum
Splitting a Text File into 1K Chunks?

1 reply on 1 page. Most recent reply: Feb 12, 2006 2:05 AM by Vijay Nathani

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 1 reply on 1 page
r f

Posts: 1
Nickname: carloslad
Registered: Feb, 2006

Splitting a Text File into 1K Chunks? Posted: Feb 11, 2006 7:26 AM
Reply to this message Reply
Advertisement
Can anyone help me? im trying to create a tiny class to take in a text file and split it into 1k chunks. thats all it has to do. im afraid my i/o is very rusty.

thanks :/


Vijay Nathani

Posts: 29
Nickname: vijaynath
Registered: Jan, 2006

Re: Splitting a Text File into 1K Chunks? Posted: Feb 12, 2006 2:05 AM
Reply to this message Reply
Here is a simple file copy program. You can modify it to break the input in chunks of 1K.

import java.io.*;
public class CharIO1 {
public static void main(String[] a) throws Exception {
BufferedReader b = new BufferedReader(
new FileReader(new File("abc.txt")));
PrintWriter p = new PrintWriter(
new BufferedWriter(new FileWriter("abc1.txt")));
int c;
while ((c = b.read()) >= 0)
p.write(c);
p.close();
b.close();
}
}

Flat View: This topic has 1 reply on 1 page
Topic: unable to locate .class file in a jar file in classpath from an application Previous Topic   Next Topic Topic: Array problem

Sponsored Links



Google
  Web Artima.com   

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