Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Rep Power

    Default Creating files using loops

    Hi.. can some one give a code for creating files using loops and to write data in to that file....

  2. #2
    Join Date
    Jun 2011
    Rep Power


    Here is the code which I have tried....can someone help me in this.....

    public class Main
    public static void main(String[] args) throws FileNotFoundException
    BufferedReader obj1 = new BufferedReader(new FileReader("D://sampleinput.txt"));
    String dest = ("D://Enhancer_Chr_Wise//");
    String s2;
    String[] s1=new String[8];
    s1 = s2.split("\t");
    String chr_no = s1[7];
    File f = new File(dest + chr_no + ".txt");
    f.write(s1[0] + s1[2] + s1[3] + s1[4] + s1[5] + s1[6]);



  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    Have you looked at the API doc to see what class to use for writing the file?
    The classes often come in pairs, there will be a writer for every reader or output for every input class.
    For example you are using BufferedReader, see if there is a BufferedWriter

    Does the File class have a write() method? What does the API doc say?

Similar Threads

  1. Creating Jar Files with functioning input files
    By appleLove in forum NetBeans
    Replies: 1
    Last Post: 04-10-2011, 10:37 PM
  2. HELP - Creating OPTIONS in program and LOOPS
    By whateverme in forum New To Java
    Replies: 14
    Last Post: 12-07-2010, 05:55 AM
  3. Creating files stopped creating...
    By Dieter in forum Advanced Java
    Replies: 3
    Last Post: 09-25-2009, 11:45 PM
  4. Replies: 2
    Last Post: 02-23-2009, 02:18 AM
  5. Creating .Jar files
    By Deathmonger in forum New To Java
    Replies: 6
    Last Post: 06-22-2008, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts