Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to divide coloumns in a text file into seperate arrays in java

Scanner scanner = new Scanner(new File(file));
ArrayList<String> animalData = new ArrayList<String>();
while (scanner.hasNext()) {
    String[] columns = scanner.nextLine().split("/t");
    String data = columns[columns.length-1];
    animalData.add(data);
    System.out.println(data);
}

int size = animalData.size();
String[] arr1 = new String[size]; String[] arr2 = new String[size]; 
String[] arr3 = new String[size]; String[] arr4 = new String[size];
for(int i=0;i<size;i++)
{
    String[] temp = animalData.get(i).split("	");
    arr1[i] = temp[0];
    arr2[i] = temp[1];
    arr3[i] = temp[2];
    arr4[i] = temp[3];
}
Comment

how to divide coloumns in a text file into seperate arrays in java

Scanner scanner = new Scanner(new File(file));
ArrayList<String> animalData = new ArrayList<String>();
while (scanner.hasNext()) {
    String[] columns = scanner.nextLine().split("/t");
    String data = columns[columns.length-1];
    animalData.add(data);
    System.out.println(data);
}

int size = animalData.size();
String[] arr1 = new String[size]; String[] arr2 = new String[size]; 
String[] arr3 = new String[size]; String[] arr4 = new String[size];
for(int i=0;i<size;i++)
{
    String[] temp = animalData.get(i).split("	");
    arr1[i] = temp[0];
    arr2[i] = temp[1];
    arr3[i] = temp[2];
    arr4[i] = temp[3];
}
Comment

PREVIOUS NEXT
Code Example
Java :: unmappable character java 
Java :: at com.rezafirstapp.simplediceroller.MainActivity$2.run(MainActivity.java:56) at java.lang.Thread.run(Thread.java:923) 
Java :: dequeue element to queue java 
Java :: trivers json node as node type 
Java :: text with seek bar in android 
Java :: stop countdown timer when exiting an activity 
Java :: https://java2blog.com/java-program-count-number-words-string/ 
Java :: java replace ignore case 
Java :: connectionpool in jdbc 
Java :: java list sort comparator date descending lambda 
Java :: what is the import for gogga class java 
Java :: uncaught error java.net.sockettimeoutexception failed to connect 
Java :: I/System.out: ep: android.os.NetworkOnMainThreadException 
Java :: java gui lookandfeel flatlaf background color 
Java :: ArrayList go to value jav 
Java :: Java/Perl - "sprintf function in java" or "string format" 
Java :: get historical data from the past to the present yahoo finance api 
Java :: random number in java between 10 and 20 
Java :: adding new field in existing kibana index using spark java 
Java :: 1 2 1 3 2 1 4 3 2 1 3 2 1 2 1 1 java 
Java :: añadir objetos de diferentes clases en una misma lista 
Java :: ternärer operator java 
Java :: Java Insert Elements to TreeSet 
Java :: Java Get float, double and String Input 
Java :: short array in java 
Java :: candies price hackerearth solution in java 
Java :: convert kotlin to java online editor 
Java :: run java in cmd 
Java :: install java 11 
Java :: string split java 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =