User Profile
Collapse
-
It still cannot run. Index of a[j] is j, not i. -
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 tLeave a comment:
-
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;
Leave a comment:
-
-
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"); }Leave a comment:
-
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"); }Leave a comment:
-
-
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)Leave a comment:
-
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.Leave a comment:
-
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[]Leave a comment:
-
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...Leave a comment:
-
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.Leave a comment:
-
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...
No activity results to display
Show More
Leave a comment: