Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
How to export 2D Array to a FIle
Dhan Priyan
Greenhorn
Posts: 12
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I need to write to the any file type ( .txt, .csv) the results obtained @ the marked place with UPPER CASE.
I am dealing with 2D array here.
could any one help me.
package associator; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.InputStreamReader; public class Test2Darray { private int[][] year2006; Test2Darray() { year2006 = new int[52][2]; } private void loadData() { try { FileInputStream fstream = new FileInputStream("E:\\missing\\java\\associator\\321236.ixf"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; int j = 0; strLine = br.readLine(); while (strLine != null) { String[] starwords = strLine.split("[ \\.,]+"); for (int i = 1; i < starwords.length; i++) { year2006[j][i - 1] = Integer.parseInt(starwords[i]); } j++; strLine = br.readLine(); } AddMissingValues addMissingValues=new AddMissingValues (); year2006 = addMissingValues.GetMissingValues2008(year2006); WRITE TO THE FILE for(int[] i:year2006) for(int k:i){ System.out.print(k+" ");} } catch (Exception e) {//Catch exception if any e.printStackTrace(); } } public static void main(String[] args) { Test2Darray arrayload= new Test2Darray(); arrayload.loadData(); } }
Rob Spoor
Sheriff
Posts: 22783
131
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What have you tried? You know how to read a file, is writing to a file that much harder?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
jittu goud
Ranch Hand
Posts: 46
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
use FileOutputStream to write your data to file
http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Reading one line from a text
Regarding reading a file in a jsp
to read lines inside brackets
Error printing out from a read in file.
Problem with reading txt file into 2d array
More...