succesfull read from file

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package sortarraytrial; /** * * @author Yokaaa */ import java.util.Arrays; import java.util.Vector; import java.util.Arrays; import java.io.*; public class SortArrayTrial { /** * @param args the command line arguments */ public static void main(String[] args) { //// TODO code application logic here // The name of the file to open. String fileName = "F:\\3rd year fcis\\movies1.txt"; // This will reference one line at a time String line = null; try { // FileReader reads text files in the default encoding. FileReader fileReader = new FileReader(fileName); // Always wrap FileReader in BufferedReader. BufferedReader bufferedReader = new BufferedReader(fileReader); int index=0; Vector<String> vectRecordFile = new Vector<String>(); Vector<Vector<String>> FileVect = new Vector<Vector<String>>(); while((line = bufferedReader.readLine()) != null) { String [] SplitLine= new String[line.length()]; vectRecordFile = new Vector<String>(); SplitLine=line.split("/"); Arrays.sort(SplitLine, 1, SplitLine.length); for (int m=0; m<SplitLine.length; m++) vectRecordFile.add(SplitLine[m]); FileVect.add(index, vectRecordFile); index++; } // for (int m=0; m<tmp1.length; m++) //{ System.out.println("record of "+m); System.out.println(FileVect); //} // Always close files. bufferedReader.close(); } catch(FileNotFoundException ex) { System.out.println( "Unable to open file '" + fileName + "'"); } catch(IOException ex) { System.out.println( "Error reading file '" + fileName + "'"); // Or we could just do this: // ex.printStackTrace(); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.