User Profile

Collapse

Profile Sidebar

Collapse
SkyGenius
SkyGenius
Last Activity: Jan 23 '07, 12:51 PM
Joined: Dec 27 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • SkyGenius
    replied to Reading data into array from file
    in Java
    It still cannot run. Index of a[j] is j, not i.
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Yes, they have same number of elements. I tried it, but it still does not work. I got this in the console:

    Exception in thread "main" java.lang.Error : Unresolved compilation problem:
    The operator + is undefined for the argument type(s) java.lang.Objec t, java.lang.Objec t
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    How could I do the operation on the ArrayList? Could I transfer all the element values in ArrayList[1] to an array?
    The following is my problem. I could not do the calculation in the main method.
    Code:
    //This in main method
    
    ArrayList[] inHAVCurve = new ArrayList[3];
    String fin2 = "inHAVCurve.txt";
    inHAVCurve = readFile3(fin2);
    
    double[] a;
    			
    for (int i=0;
    ...
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Thanks so much for your advice.
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Code:
    FileWriter fout1 = new FileWriter("output1.txt");
    for (int i = 0; i < inWL[0].size(); i++) {
    	System.out.println(inWL[0].get(i) + " " + inWL[1].get(i));
    	fout1.write(inWL[0].get(i) + " " + inWL[1].get(i) + "\n");
    }
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    I can run the class. But when I use "space delimited format" for an input file, I could not write all read data to a file. The read data are displayed normally when I write it to the console.

    Code:
    for (int i = 0; i < inWL[0].size(); i++) {
    	System.out.println(inWL[0].get(i) + " " + inWL[1].get(i));
    	fout1.write(inWL[0].get(i) + " " + inWL[1].get(i) + "\n");
    }
    ...
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Thanks so much. It is running!
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    It shows this in console:
    Exception in thread "main" java.lang.NullP ointerException
    at fileReading.rea dFile2(fileRead ing.java:95)
    at fileReading.mai n(fileReading.j ava:49)
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Thanks so much for your help. I can successfully run the first method (readFile). But I still cannot run the second method (readFile2). It seems there are problems in declaration of dataArray3, calling method readFile2 and in the method itself.
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Please help to fix this code.

    Code:
    import java.io.*;
    import java.util.*;
    
    public class ReadingFile {
    
    public static void main(String args[]) {
    	// You put your logic here
    	int i,j;
    	int count1,count2;		// number of the array elements
    	
    	int maxSize1 = 100;		// max number of array elements
    	double[] dataArray1 = new double[maxSize1];
    	double[]
    ...
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Could you make it in a complete class that is ready to run? For example, there is two files for the first format (so there are two arrays) and one file for second format (so there are three arrays). I would like to get those arrays in double type and it is ready to use for computation. Then I would like to write the two arrays from the first format to one file with two columns (first column for first array and second column for second array) . The...
    See more | Go to post

    Leave a comment:


  • SkyGenius
    replied to Reading data into array from file
    in Java
    Thanks for your help and comments. If possible, I would like to use two different methods to read the two different formats of the data files.
    See more | Go to post

    Leave a comment:


  • SkyGenius
    started a topic Reading data into array from file
    in Java

    Reading data into array from file

    Hello, I am a new Java learner. I would like to develop one model by using Java. In that model, there are many files to read. I want to write a method in Java to read a file and store the data in array(s). Later, I just only call that method to read other files. Would you please help me to write a code to read the data in the following formats:

    First format (for example, separated by lines): store one column of the data in one array...
    See more | Go to post
No activity results to display
Show More
Working...