Results 1 to 3 of 3
Thread: Creating files using loops
- 06-07-2011, 05:00 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 24
- Rep Power
- 0
- 06-07-2011, 05:03 PM #2
Member
- Join Date
- Jun 2011
- Posts
- 24
- Rep Power
- 0
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];
while((s2=obj1.readLine())!=null)
{
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]);
}
}
}
- 06-07-2011, 05:09 PM #3
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
-
Creating Jar Files with functioning input files
By appleLove in forum NetBeansReplies: 1Last Post: 04-10-2011, 10:37 PM -
HELP - Creating OPTIONS in program and LOOPS
By whateverme in forum New To JavaReplies: 14Last Post: 12-07-2010, 05:55 AM -
Creating files stopped creating...
By Dieter in forum Advanced JavaReplies: 3Last Post: 09-25-2009, 11:45 PM -
trouble creating program using loops for multiplication table
By cuse17 in forum New To JavaReplies: 2Last Post: 02-23-2009, 02:18 AM -
Creating .Jar files
By Deathmonger in forum New To JavaReplies: 6Last Post: 06-22-2008, 11:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks