Note that there are some explanatory texts on larger screens.

plurals
  1. POpass the code of java to work for java/android
    primarykey
    data
    text
    <p>I have 3 .java files: main.java, separetdat.java and token.java </p> <h2>main.java</h2> <pre><code>import java.util.*; public class Main { public static void main(String[] args) { Tokenizer ob1=new Tokenizer(); LinkedList listaDeCoord=new LinkedList(); SepararDatos oSepararDatos=new SepararDatos(); ob1.leerPath(); ob1.getDataFromFile(); listaDeCoord=ob1.listaTokens; listaDeCoord=oSepararDatos.getLinkedList(listaDeCoord); double[] vectorDeDatos; //= new double[listaDeCoord.size()]; double[] vectorIndex; vectorDeDatos=oSepararDatos.getArrayData(listaDeCoord); vectorIndex=oSepararDatos.getArrayIndex(vectorDeDatos); } } </code></pre> <h2>separetdat.java:</h2> <pre><code>import java.util.*; public class SepararDatos { public void SepararDatos() { } public double[] getArrayIndex(double[] vector) { double[] vectorIndex=new double[vector.length/3]; int index=0,i=0; while (index&lt;vector.length) { vectorIndex[i]=vector[index]; index=index+3; i++; } return vectorIndex; } public LinkedList getLinkedList(LinkedList lista) { String linea=""; StringTokenizer st; String palabra=""; LinkedList palabras=new LinkedList(); //lista=new LinkedList(); int j=0; char c; int indice=0; for (int i=0;i&lt;lista.size();i++) { linea=lista.get(i).toString(); st=new StringTokenizer(linea); while (st.hasMoreTokens()) { palabras.add((st.nextToken())); } } return palabras; } public double[] getArrayData(LinkedList lista) { double[] vectorPalabras=new double[lista.size()]; for (int i=0;i&lt;vectorPalabras.length;i++) { vectorPalabras[i]=Double.parseDouble(lista.get(i).toString()); } return vectorPalabras; } } </code></pre> <h2>token.java</h2> <pre><code>import java.io.*; import java.util.*; public class Tokenizer { String strFile; BufferedReader br; String strLine; StringTokenizer st = null; int lineNumber = 0, tokenNumber = 0; LinkedList lista=new LinkedList(); LinkedList listaTokens=new LinkedList(); public void Tokenizer() { } public void leerPath () { strFile = "path of the txt file.txt"; try { br = new BufferedReader( new FileReader(strFile)); } catch(Exception e) { System.out.println("Exception while reading csv file: " + e); } } public double[] getDataFromFile() { double[] vector=new double[lista.size()]; try { while( (strLine = br.readLine()) != null) { lineNumber++; //break comma separated line using "," //st = new StringTokenizer(strLine, ","); st = new StringTokenizer(strLine); while(st.hasMoreTokens()) { //display csv values System.out.println("Line # " + lineNumber + ", Token # " + tokenNumber + ", Token : "+ st.nextToken()); tokenNumber++; } //reset token number tokenNumber = 0; lista.add(strLine); } } catch(Exception e) { System.out.println("Exception while reading csv file: " + e); } listaTokens=lista; for (int i=0;i&lt;vector.length;i++) { vector[i]=Double.parseDouble(lista.get(i).toString()); } return vector; } } </code></pre> <p>When I create the java project, it works perfectly, but when I create an Android project, it does not work. What do I need to change the original java code so that it works in Android?</p> <hr> <p>im sorry for my question to be how to put it mmmm dumb basically what i like to now is how to call the methods from the other 2 clases in Activity, activity has to call form the other 2 classes, simple example will be let say activity.java has to call from calculate.java the method that prints out the result</p> <p>activity.java calls result from sum calls result from multiply prints the results</p> <p>name.java let say it does a sum in one function return sum result.</p> <p>2 function does multiply 2 numbers returm multiply results.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload