Array to store .txt file data

I have a .txt file containing lines like the following:
1,50000.343,2000.745
2,25645.856,4600,856
3,24356.756,8766,345
I'd like to store the strings as numbers and place them into an array, but I'm unsure how to do so.
Any help would be appreciated

The StreamTokenizer class will help you read the input, separating numbers from commas. Once you have the number as a String, the classes like Double and Integer have constructors that accept String arguments and do the hard work for you:
// someString came from the file
// you checked to see if it had a "." and it didn't, so
// you know it's an integer
Integer myInteger = new Integer( someString );
int myInt = myInteger.getInt();

Similar Messages

  • Only writing Integer pixel array to a .txt file,or showing in Frame

    Sir,
    I want to write integer values (range:0 to 255) to a .txt file .Actually after manipulating a .jpeg/.gif image I have gotten a 2D pixel array and a 1D pixel array that can be easily shown in console but I want to write this pixel array into a .txt file. Using of writeInt() is not working. Actually after using this faction the created file contain information which is non-alphanumeric /alphanumeric characters......
    following is error free the code: Plz. See only and only into the �class TestImage�and plz look after line marked by //�my_problem_to_be_resolved.�It is just few lines of code .I promise you will not be bothered.Plz��..
    import java.awt.*;
    import java.io.File;
    import java.io.FileWriter;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;
    class Image {
    protected int width,height;
    // 'samples' stores the image pixel values.
    protected int[][] samples;
    // Constructor: Reads the image from the
    // specified file name.
    public Image(String filename)
    throws Exception { read(filename); }
    // Returns the pixel width of the image.
    public int getWidth() { return width; }
    // Returns the pixel height of the image.
    public int getHeight() { return height; }
    // Reads the image from the specified file
    // name into the 'samples' array. Throws an
    // exception if the image is stored in an
    // unsupported file format (currently only
    // .GIF, .JPG, and .PNG are supported by Sun).
    public void read(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageReaders that claim
    // to be able to decode this image file
    // based on the file name suffix.
    Iterator imageReaders = ImageIO.
    getImageReadersBySuffix(ext);
    ImageReader imageReader;
    // Grab the first ImageReader in the list.
    if (imageReaders.hasNext())
    imageReader = (ImageReader)
    imageReaders.next();
    // If we get here we cannot decode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file input stream object to
    // read the image date.
    FileImageInputStream imageInputStream =
    new FileImageInputStream(fileImage);
    // Tell the ImageReader object to read data
    // from our file input stream object.
    imageReader.setInput(imageInputStream);
    // Get the width and height of the image.
    width = imageReader.getWidth(0);
    height = imageReader.getHeight(0);
    // Read the image from the file input stream,
    // and close the input stream when done.
    BufferedImage bufImage =
    imageReader.read(0);
    imageInputStream.close();
    // Get a raster object so we can extract the
    // pixel data from the BufferedImage.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Create our 'samples' 2d-array.
    samples = new int[height][width];
    // Extract the image data into our 'samples'
    // array.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    samples[row][col] =
    wRaster.getSample(col,row,0);
    // Write the image stored in the 'samples'
    // array to the specified file. The file name
    // suffix should be a supported image file
    // format (currently either .JPG or .PNG).
    public void write(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageWriters that claim to
    // be able to encode images in the specified
    // image file format based on the file name
    // suffix.
    Iterator imageWriters = ImageIO.
    getImageWritersBySuffix(ext);
    ImageWriter imageWriter;
    // Grab the first ImageWriter in the list.
    if (imageWriters.hasNext())
    imageWriter = (ImageWriter)
    imageWriters.next();
    // If we get here we cannot encode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file output stream object to
    // write the image data.
    FileImageOutputStream imageOutputStream
    = new FileImageOutputStream
    (fileImage);
    // Tell the ImageWriter to use our file
    // output stream object.
    imageWriter.setOutput
    (imageOutputStream);
    // The ImageWriter.write() method expects a
    // BufferedImage. Convert our 'samples' array
    // into a BufferedImage.
    BufferedImage bufImage =
    createBufferedImage();
    // Encode the image to the output file.
    imageWriter.write(bufImage);
    imageOutputStream.close();
    // Draws the image stored in the 'samples'
    // array on the specified graphics context.
    public void draw(Graphics gc,int x,int y){
    BufferedImage bufImage =
    createBufferedImage();
    gc.drawImage(bufImage,x,y,null);
    // Converts the 'samples' array into a
    // BufferedImage object. Students do not have
    // to understand how this works.
    private BufferedImage
    createBufferedImage() {
    // Create a monochrome BufferedImage object.
    BufferedImage bufImage = new
    BufferedImage(width,height,
    BufferedImage.TYPE_BYTE_GRAY);
    // Create a WriteableRaster object so we can
    // put sample data into the BufferedImage
    // object's raster.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Copy the 'samples' data into the
    // BufferedImage object's raster.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    wRaster.setSample
    (col,row,0,samples[row][col]);
    // Return the newly created BufferedImage.
    return bufImage;
    } // End of Class Image
    class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/lilies.jpg");
    int height=img.getHeight();
    int width =img.getWidth();
    //�my_problem_to_be_resolved.�
         File image_object_arry=new File("C:/Image_array.txt");
         FileOutputStream image_object_arry_stream= new FileOutputStream(image_object_arry);
         DataOutputStream int_image_object_arry_stream=new DataOutputStream(image_object_arry_stream);
    //Conversion of two dimensional pixel arrry into one dimensional array
    int intPixels1[] = new int [height * width];
    int k = 0;
    for(int i = 0; i <= width; i++) {
    for(int j = 0; j <= height; j++) {
    intPixels1[k] = img.samples[i][j];
    int_image_object_arry_stream.writeInt((int) intPixels1[k]);
    // System.out.println(intPixels1[k]);
    k = k+1;
    import java.awt.*;
    import java.io.File;
    import java.io.FileWriter;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;
    class Image {
    protected int width,height;
    // 'samples' stores the image pixel values.
    protected int[][] samples;
    // Constructor: Reads the image from the
    // specified file name.
    public Image(String filename)
    throws Exception { read(filename); }
    // Returns the pixel width of the image.
    public int getWidth() { return width; }
    // Returns the pixel height of the image.
    public int getHeight() { return height; }
    // Reads the image from the specified file
    // name into the 'samples' array. Throws an
    // exception if the image is stored in an
    // unsupported file format (currently only
    // .GIF, .JPG, and .PNG are supported by Sun).
    public void read(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageReaders that claim
    // to be able to decode this image file
    // based on the file name suffix.
    Iterator imageReaders = ImageIO.
    getImageReadersBySuffix(ext);
    ImageReader imageReader;
    // Grab the first ImageReader in the list.
    if (imageReaders.hasNext())
    imageReader = (ImageReader)
    imageReaders.next();
    // If we get here we cannot decode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file input stream object to
    // read the image date.
    FileImageInputStream imageInputStream =
    new FileImageInputStream(fileImage);
    // Tell the ImageReader object to read data
    // from our file input stream object.
    imageReader.setInput(imageInputStream);
    // Get the width and height of the image.
    width = imageReader.getWidth(0);
    height = imageReader.getHeight(0);
    // Read the image from the file input stream,
    // and close the input stream when done.
    BufferedImage bufImage =
    imageReader.read(0);
    imageInputStream.close();
    // Get a raster object so we can extract the
    // pixel data from the BufferedImage.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Create our 'samples' 2d-array.
    samples = new int[height][width];
    // Extract the image data into our 'samples'
    // array.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    samples[row][col] =
    wRaster.getSample(col,row,0);
    // Write the image stored in the 'samples'
    // array to the specified file. The file name
    // suffix should be a supported image file
    // format (currently either .JPG or .PNG).
    public void write(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageWriters that claim to
    // be able to encode images in the specified
    // image file format based on the file name
    // suffix.
    Iterator imageWriters = ImageIO.
    getImageWritersBySuffix(ext);
    ImageWriter imageWriter;
    // Grab the first ImageWriter in the list.
    if (imageWriters.hasNext())
    imageWriter = (ImageWriter)
    imageWriters.next();
    // If we get here we cannot encode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file output stream object to
    // write the image data.
    FileImageOutputStream imageOutputStream
    = new FileImageOutputStream
    (fileImage);
    // Tell the ImageWriter to use our file
    // output stream object.
    imageWriter.setOutput
    (imageOutputStream);
    // The ImageWriter.write() method expects a
    // BufferedImage. Convert our 'samples' array
    // into a BufferedImage.
    BufferedImage bufImage =
    createBufferedImage();
    // Encode the image to the output file.
    imageWriter.write(bufImage);
    imageOutputStream.close();
    // Draws the image stored in the 'samples'
    // array on the specified graphics context.
    public void draw(Graphics gc,int x,int y){
    BufferedImage bufImage =
    createBufferedImage();
    gc.drawImage(bufImage,x,y,null);
    // Converts the 'samples' array into a
    // BufferedImage object. Students do not have
    // to understand how this works.
    private BufferedImage
    createBufferedImage() {
    // Create a monochrome BufferedImage object.
    BufferedImage bufImage = new
    BufferedImage(width,height,
    BufferedImage.TYPE_BYTE_GRAY);
    // Create a WriteableRaster object so we can
    // put sample data into the BufferedImage
    // object's raster.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Copy the 'samples' data into the
    // BufferedImage object's raster.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    wRaster.setSample
    (col,row,0,samples[row][col]);
    // Return the newly created BufferedImage.
    return bufImage;
    } // End of Class Image
    /*class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/srk.jpg");
    // Display the image.
    img.draw(gc,10,40);
    // Flip the image upside down
    //img.flipX();
    // Display the flipped image.
    img.draw(gc,20+img.getWidth(),40);
    // Write the new image to a file
    img.write("HorseNew.jpg");
    } catch (Exception e) {
    System.out.println
    ("Exception in main() "+e.toString());
    class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/lilies.jpg");
    int height=img.getHeight();
    int width =img.getWidth();
    File image_object_arry=new File("C:/Image_array.txt");
    FileOutputStream image_object_arry_stream=new FileOutputStream(image_object_arry);
         DataOutputStream int_image_object_arry_stream=new DataOutputStream(image_object_arry_stream);
    //Conversion of two dimensional pixel arrry into one dimensional array
    int intPixels1[] = new int [height * width];
    int k = 0;
    for(int i = 0; i <= width; i++) {
    for(int j = 0; j <= height; j++) {
    intPixels1[k] = img.samples[i][j];
    int_image_object_arry_stream.writeInt((int) intPixels1[k]);
    // System.out.println(intPixels1[k]);
    k = k+1;
    catch (Exception e) {
    System.out.println("Exception in main() "+e.toString());
    catch (Exception e) {
    System.out.println("Exception in main() "+e.toString());
    }

    My Friend, you need to put your code within CODE tags
    And I suspect if anyone would go through your code this way.
    Assuming your problem is to write pixel values to a file you may use this,
          try{
            // Create file
            FileWriter fstream = new FileWriter("out.txt");
            BufferedWriter out = new BufferedWriter(fstream);
            for(int i =0; pixels.length() ; i++)
              out.write(pixels[i]+"\t");
           //Close the output stream
           out.close();
           }catch (Exception e){//Catch exception if any
          System.err.println("Error: " + e.getMessage());
        }

  • Store txt file to 2darray

    I make afunction that save a 2darray into atx using this code
        private boolean saveArray(File filename, double[][] output_veld) {
            try {
               PrintWriter out =
               new PrintWriter (new BufferedWriter (new FileWriter (filename)));
               out.print (Arrays.deepToString(output_veld));
               out.flush ();
               out.close ();
            catch (IOException e) {
               return false;
            return true;
    }I want to store again the data in txt file into the 2darray I tried this code
    public String readFile (File file) {
    double a [][] = new double [3][3];
        StringBuffer fileBuffer;
        String line;
        try {
          FileReader in = new FileReader (file);
          BufferedReader dis = new BufferedReader (in);
          fileBuffer = new StringBuffer () ;
          while ((line = dis.readLine ()) != null) {
                fileBuffer.append (line + "\n");
          in.close ();
          a =  the problem is here !! how I can insert the data on the array
        catch  (IOException e ) {
          return null;
        return fileString;
      }

    hi,
    I tried it like that ...
        boolean saveFile () {
          File file = null;
          JFileChooser fc = new JFileChooser ();
          fc.setCurrentDirectory (new File ("."));
          fc.setFileFilter (fJavaFilter);
          fc.setSelectedFile (fFile);
          int result = fc.showSaveDialog (this);
          if (result == JFileChooser.CANCEL_OPTION) {
              return true;
          } else if (result == JFileChooser.APPROVE_OPTION) {
              fFile = fc.getSelectedFile ();
              if (fFile.exists ()) {
                  int response = JOptionPane.showConfirmDialog (null,
                    "Overwrite existing file?","Confirm Overwrite",
                     JOptionPane.OK_CANCEL_OPTION,
                     JOptionPane.QUESTION_MESSAGE);
                  if (response == JOptionPane.CANCEL_OPTION) return false;
              String content = fFile.toString();
              return saveArray (content,drawLines1);
          } else {
            return false;
        public boolean saveArray(String filename, double[][] output_veld) {
                 try {
                    FileOutputStream fos = new FileOutputStream(filename);
                    ObjectOutputStream out = new ObjectOutputStream(fos);
                    out.writeObject(output_veld);
                    out.flush();
                    out.close();
                 catch (IOException e) {
                     System.out.println(e);
                     return false;
                  return true;
              }but when I opened the saved txt file I didnt get data I get some things liek that!!
    ? ur [[D?dgE  xp  ?ur [D>?cZ  xp   @V      @F      @g?     @[?     ?                       uq ~    @p?     @b     @w@     @m      ?                       uq ~    @{`     @u0     @{      @x0     ?                       uq ~    @s      @y      @j@     @u      ?                       uq ~    @uP     @r?     @|?     @p     ?                       uq ~    @     @b?     @sp     @O      ?                       uq ~    @n@     @f      @f      @p?     ?                       uq ~    @t      @w      @x?     @y`     ?                       uq ~    @y      @}?     @??     @v     ?                       uq ~    @?      @rP     @{?     @f`     ?                       uq ~    @a     @j`     @l      @q     @                      uq ~    @l      @q     @up     @g      @                      uq ~    @up     @g      @o      @|     @                      uq ~    @o      @|     @d      @t     @                      uq ~    @d      @t     @z      @q?     @                      uq ~    @z      @q?     @~     @f      @                      uq ~    @xp     @s      @rP     @xP     @                      uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~    

  • How to store txt file into Oracle 7 Database using Pro*C

    Hi,
    I want to store a txt file into Oracle 7 database table using
    Pro*C application. But do not know what type of column to use.
    At first glance it appeared to me as LONG can serve the purpose
    but later I noticed that I can not do the sequential read/write
    in LONG type of column. That is, I have to use chunks of max of
    2GB (or file lenght) to read/write into such columns.
    I want something simiar to CLOB of Oracle 8.
    I would appreciate if you can provide me solution.
    Thanks,
    Anurag

    You store images in a BLOB column in the database.
    However, inserting image in that column and displaying data/image from that column are 2 very different tasks.
    If you are using Oracle forms, displaying is easy. Default block sitting on the table with BLOB column, can be easily mapped to image box (or similar control), which will display that image.
    Inserting images will be a different ball game. If your forms are web based (i.e. run from browser) and you want to insert images from client machine, some special arrangements are required.
    If images are on database server and you want to insert them in database, the stored procedure given in the earlier thread (posted above) will do the job.

  • Is there a way to create a button on the front panel that would automatically open the txt file data is being stored to?

    I am saving data read from FieldPoint to a .txt file. Is there a way to create a button on the front panel so that when the user pushes this button it automatically opens the .txt folder in notepad? I want to bypass the user having to find the file in the computer in order to open it.

    Hi jem,
    I suggest that you break this up into three seperate questions and re-post to this list. That way you get more ideas from others that may have better insites than myself.
    Re:the sysexec
    The Sysexec will allow you to execute a dos command. This is the equivalent of going to
    Start>>>Run
    What you should do is find the proper DOS command sysntax that is required to open a text file in notepad or your favorite editor. Once you know what a good DOS command is, you should pass that string to the Sysexec.VI. The Sysexec has an input that allows you to choose if the code waits for the command to complete or if it should just start the program and let it run in the background. Sysexec will open its own window to run the command you speci
    fiy.
    Ben
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Regarding TXT File data truncation due to large amount of data

    Hi Guys,
    I am downloading data to txt.file in background.I am getting truncation of the records due to large amount of data. If it is less data it works good.
    I have checked the Internal table SIZE for this and anywhy i have declared in OCCURS 0 only.
    So please help me to find out what may this reason.I am confuced is there any limitation for TXT file??
    Please help me guys..
    Thanks in advance..
    Prabhu.R

    Hi Rakesh,
    two ways.
    1. Ask ur BASIS team to increase the memory level.
    2. Check the PACKAGE SIZE option of select statement
    Here u  won't select all the data once but in packets of specified size. So get the packets of data and process.
    Just press F1 on package size. That explanation will be enough to proceed further.
    Thanks,
    Vinod.

  • Saving an integer array into a .txt file

    hii, im only a beginner in java, so this is the only code i've learned so far for saving array elements into a file
         public static void saveNames(String [] name) throws IOException
                   FileWriter file = new FileWriter("Example\\names.txt");
                   BufferedWriter out = new BufferedWriter(file);
                   int i = 0;
                   while (i < name.length)
                             if (name[i] != null)
                                  out.write(name);
                                  out.newLine();
                                  i++;
                   out.flush();
                   out.close();
    However, this is only used for string arrays; and i can't call the same method for an integer array (because it's not compatible with null)
    I don't really understand this code either... since my teacher actually just gave us the code to use, and didn't really explain how it works
    I have the same problem for my reading a file code as well --> it's only compatible with string
         public static String [] readNames (String [] name) throws IOException
              int x = 0;
              int counter = 0;
              String temp = "asdf";
              name = new String [100];
              FileReader file = new FileReader("Example\\names.txt");
              BufferedReader in = new BufferedReader(file);
              int i = 0;
              while (i < array.length && temp != null)                    // while the end of file is not reached
                   temp = in.readLine();
                   if (temp != null)
                        name[i] = temp;                    // saves temp into the array
                   else
                        name[i] = "";
                   i++;
              in.close();                                   // close the file
              return name;
    Could someone suggest a way to save elements from an integer array to a file, and read integer elements of that file?
    Or if it's possible, replace null with a similar variable (function?), that is suitable for the integer array (i can't use temp != 0 because some of my elements might be 0)
    Thanks so much!!!!!

    because it's not compatible with nullI think it should be okay to just remove the null condition check since there are no null elements in a primitive array when writing.
    Use Integer.parseInt() [http://java.sun.com/javase/6/docs/api/java/lang/Integer.html] to convert the String into an Integer when you read it back and use Integer.toString() to be able to write it as a String.

  • Can I store .txt files in a jar and read them?

    I have searched the forum and didn't find exactly what I needed.
    I have multiple .txt files that will most likely not change over time. I have a class that reads them as needed. I need to do this in a jar file but can not seem to read the .txt files.
    Any help?

    You should be able to read them using an idiom like this:
    URL textURL = MyClass.class.getResource("res/txt/TextResourceFile.txt");where MyClass is the name of a class, and the specified path is relative to the location of that class.
    I haven't actually tried this for text files, but I do use it to load images, so it ought to work for this too.

  • Getting .txt file data from servlet

    I am having problem finding the file I use "reguli.txt" to define page rules of a website.
    I use this file in a servlet.The file I copied it in the project folder,and also in /web/web-inf folder.
    The problem is I cant find the file without using all the path in this line: File filename = new File("reguli.txt");
          String filepath = filename.getAbsolutePath();
                FileInputStream file = new FileInputStream(filepath);
                InputStreamReader isr = new InputStreamReader(file);
                BufferedReader br = new BufferedReader(isr); I tried also:
    ServletContext context = getServletContext();
                InputStream contextPath = context.getResourceAsStream("/reguli.txt");
                InputStreamReader isr = new InputStreamReader(contextPath);
                BufferedReader br = new BufferedReader(isr);And I still get the same error:
    SEVERE: StandardWrapperValve[Servleet]: PWC1406: Servlet.service() for servlet Servleet threw exception
    java.io.FileNotFoundException: D:\Users\Stefan\GlassFish_v3_Prelude\glassfish\reguli.txt (The system cannot find the file specified)
    What am I doing wrong?

    Put the file directly under your webapps root context and access using following code
            String filename = "/InputFile.txt";
            ServletContext context = getServletContext();
            InputStream is = context.getResourceAsStream(filename); regards,
    nirvan.

  • How to read this kind of array from a txt file?

    I have been trying to read this file given below.
    Please have a look at 4th line, there is a gap between 89 and 32.
    I want to read a gap as a "0" value, and convert all values to integer.
    I have been using split function, but I still don't know how to figure the gap problem.
    Please help me, thanks.
    1 60 72 88 41 58
    2 50 45 37 86 13
    3 44 41 99 54 24
    4 12 89 32 89
    5 48 97 25 85 55
    6 22 46 34 90 98
    7 75 85 5 1
    8 86 23 39 69 52
    9 42 18 75 13 72
    10 24 77 27 18 30
    11 34 42 5 12
    12 31 87 47 75 8
    13 19 16 74 55 77
    14 26 57 5 63 81
    15 51 7 95 100 8
    16 33 93 82 85 72
    17 55 21 49 25 3
    18 15 29 33 18 61
    19 33 42 64 66 63
    20 51 36 97 39 19
    21 51 60 32 25 51
    22 88 34 29 76 10
    23 37 93 9 38 100
    -------------------------------------------

    scan each line with the following code
    it adds each line to a new array
    //scan file
            try {
                Scanner Filescan = new Scanner(new File("directory"));
                while (Filescan.hasNextLine()) {
                Array.add(Filescan.nextLine());
                catch (Exception e)
                System.out.println (" File has not been found");
                } 

  • Write array into txt file

    Hi Guys!
    I need a VI which writes the content of an array into a txt file.
    I have an array like this:
    Peti    Teri
    Zoli    Hajni
    Tomi    Heni
    Pali    Robi
    In the file the first line should be a full timestamp (date, time), and then would come the content of the array. The name of the file would also be a timestamp.
    Thank you for your help in advance!

    Hi Victronica and welcome to NI Forums!
    If you have some custom data, then it is up to ou to tell excel how to interpret said data (what information to put where, etc.) A simple solution would be to flatten your cluster elements into strings, and write those strings into an excel sheet using ActiveX. An example on how to write a table of strings is available in the example finder, and I also have it attached here in LabVIEW 2013.
    Kind regards:
    Andrew Valko
    National Instruments Hungary
    Attachments:
    Excel - Write Table.vi ‏17 KB

  • How do i use array to store a readfile information?

    currently i m facing with this problem, i have a set of .txt file data which look like below:
    6 6 3 10 3 5
    6 8 4 10 8 6
    10 17 1 11 1 1
    7 18 3 10 3 5
    8 19 1 11 1 1
    10 20 2 11 1 5
    7 20 4 10 8 6
    8 22 2 11 1 5
    10 25 4 10 8 6
    10 26 7 11 1 8
    8 27 8 12 1 11
    8 28 7 11 1 8
    10 30 9 9 8 11
    8 31 11 12 3 12
    10 32 10 11 1 12
    now i'm using while ((text = in.readLine()) != null) to read this set of data.
    how do i can store this set of data into array form as below??
    int [ ][ ] data = new String [100][6];
    //6 6 3 10 3 5 1st row
    data[0][0] = ( "6" );
    data[0][1] = ( "6" );
    data[0][2] = ( "3" );
    data[0][3] = ( "10" );
    data[0][4] = ( "3" );
    data[0][5] = ( "5" );
    //6 8 4 10 8 6 2nd row
    data[1][0]= ("6");
    data[1][1]= ("8");
    data[1][2] = ( "4" );
    data[1][3]= ("10");
    data[1][4]= ("8");
    data[1][5] = ( "6" );

    Well using the String.split() method you may be able to turn each line into an array of String numbers. So if you want an array of integers, you'll need to convert each index with Integer.parseInt().

  • Txt file creation

    Hi everyone,
    I need your help.
    There are many threads on txt creation in that forum but I couldn't find the one that answers to my questions.
    I'd like to create a txt containing one Header (FILE EDITOR, Time and Date) and  ten columns of data. Every column should be preceded (on top) by the words COLUMN1 to COLUMN10.
    The created file should also contain the time and date of creation.
    Please see the attached files.
    Best regards
    Kabanga
    Attachments:
    Write_file.vi ‏44 KB
    data.txt ‏2 KB

    Hi guys,
    Thanks for your help!
    I did the modifications you advised me. It's working well:
    Now I'd like the following: If make "SAVE" for the same file three times, I'd like it to be like in the attached txt file (data):
    How can I implement it?  I've  tried it with "Set File Position" but it's not working.
    Best regards
    Kabanga
    Attachments:
    data.txt ‏4 KB
    Write_file.vi ‏52 KB

  • Parameters in Transformations file "data export"

    Hi,
    i'm trying to export to a txt file data from SAP BPC to a txt file, using the standard package (Export Transactional Data).
    I have several issues. Firstly, it seems like the dataexport generates a lot of lines containing all the "PARENT" calculations. So my file is perpaps only 30 lines on basemember level, but the final flatfile is perhaps 3.000 lines due to all the calculated lines (on parents level).
    Is there any way to "disable" all these parent calculated lines in the export ?
    Also i've tried finding some examples on transformation files for dataexport, but can not find any.
    Does anyone know which parameters I can use in the *option section of the transformation file ?
    Thank you,
    Joergen Dalby

    If you can access the other machine like a share folder then provide the same path in physical schema like \\my_other_pc_on_shared\new_folder
    If you cannot access like that then create one agent on that machine which can access the path and execute your project using the agent.
    Thanks
    Bhabani
    http://bhabaniranjan.com/

  • Cache creation hang on .txt file

    I have 50+ sites defined.
    This one directory hangs on site cache creation and
    dreamweaver never gets past any file.
    I thought it might have been a specific file, and have
    removed one after another to discover it doesn't care what the file
    is, it just fails to create a site on this directory, or anything
    containing this directory.
    I have checked permissions and am stumped by this.
    Any ideas?

    Hi guys,
    Thanks for your help!
    I did the modifications you advised me. It's working well:
    Now I'd like the following: If make "SAVE" for the same file three times, I'd like it to be like in the attached txt file (data):
    How can I implement it?  I've  tried it with "Set File Position" but it's not working.
    Best regards
    Kabanga
    Attachments:
    data.txt ‏4 KB
    Write_file.vi ‏52 KB

Maybe you are looking for

  • My Macbook is not starting up

    Hi there, I'm a bit desperate here as my Macbook just turned down and won't start up again. I thought it turned off because the battery wasn't charged (the signal is actually broken so I never know how much the battery level is - I often leave it att

  • Package does not exist error-message

    When I try to compile a java servlet with the following piece of code I get a compilation error referring to the import statement. I have just included the initial import statements. A large number of errors follow, as a result of this 'package does

  • Adobe comparison abruptly closes at completion

    I am trying to compare two PDFs of 800+ pages of text and some figures. The comparison tool seems to perform just fine when I designate a block of pages for comparison to about 10 pages, but when I compare larger blocks (i.e. 20-250) Adobe and all ad

  • ADF BC from standalone java program

    Hi, looking for a code sample for creating an AM and using it within a standalone Java package. I have an ADF BC package developed that I need to use via a command line java class. thanks, Brenden

  • NAT port forwarding

    I have recently purchased a Cisco 871 router. In the GUI from the installed software, I have been able to configure which ports are forwarded to a specified IP address within my local area network. This seems to output a configuration line like this: