Problem with reading numbers from file into double int array...

Okay, this is a snippet of my code:
public void readMap(String file){
        try {
            URL url = getClass().getResource(file);
            System.out.println(url.getPath());
            BufferedReader in = new BufferedReader(new FileReader(url.getPath()));
            String str;
            String[] temp;
            int j=0;
            while ((str = in.readLine()) != null) {
                temp = str.split(",");
                for(int i=0;i<temp.length;i++){
                    map[j] = java.lang.Integer.parseInt(temp[i]);
j++
in.close();
} catch (IOException e) {
System.out.println("Error: "+ e.toString());
map[][] is a double int array. Now, the code is running through each line of the text file (with each line looking like this: 0,3,6,2,2,3,1,5,2,3,5,2), and I want to put the numbers into a corresponding double int array (which is where map[][] comes in). Now, this code WOULD work, except I need to set the sizes of each array before I start adding, but I don't know how to get the exact sizes.. how can I get around this issue?
Message was edited by:
maxfarrar

You can do a two-dimensional ArrayList? That syntax
you wrote didn't work.
I tried doing:
private ArrayList<ArrayList><Integer>> map;
Your syntax is just wrong -- or, this forum software has bug in handling angle brackets.
ArrayList<ArrayList<Integer>>...The closing angle bracket after the second 'ArrayList' is the one generated by the bug. Basically, it should be T<T<T2>> without spaces. Oh, for that matter:
Arraylist<ArrayList<Integer>>

Similar Messages

  • Help! Problem with reading objects from file

    I wrote a "Library" program for an assignment, and one of the requirements is that the library store all of its information to file upon exit, and reload this information from file when run.
    Well, the writing to file part is working. I'm using a FileOutputStream object and an ObjectOutputStream object. I can tell from the file size of the .dat file that information is going into it.
    But what I can't do is read from file. For that, I'm using a FileInputStream and an ObjectInputStream. I keep getting this exception:
    java.io.EOFException
         at java.io.DataInputStream.readInt(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readInt(Unknown Source)
         at java.io.ObjectInputStream.readInt(Unknown Source)
         at Library.readDataFromFile(Library.java:350)
         at Library.<init>(Library.java:63)
         at LibraryDriver.main(LibraryDriver.java:6)I looked this exception up and it says it's thrown when a data input stream unexpectedly ends....But I am instantiating the input streams just before I try to read from file:
                            fileInStream = new FileInputStream(libraryFile);
                   objInStream = new ObjectInputStream(fileInStream);
                   Object[] objectArray = new Object[objInStream.readInt()];Both input streams have methods that "return the number of bytes that can be read from this file input stream without blocking". Just for kicks, I tried writing that number to the console.
    For the FileInputStream, I get 404 bytes.
    For the ObjectInputStream, I get 0 bytes.
    So I guess it's a problem with the ObjectInputStream? Anyone have any suggestions as to how I can fix this, please?

    Yep, here's the relevant code from the writeToFile() method:
                          for (int i = 0; i < libraryAuthors.length; i++) {
                        currentAlphaAuthorList = libraryAuthors;
                        for (int j = 0; j < currentAlphaAuthorList.size(); j++) {
                             currentAuthor = (Author) currentAlphaAuthorList.get(j);
                             objOutStream.writeObject(currentAuthor);
                   objOutStream.flush();
                   objOutStream.close();

  • A problem with importing layered PSD file into Flash

    Hi.
    There's a problem with importing layered PSD file into Flash.
    If I import a layered PSD file, some part the color of the lower layer is shown at the edge of objects or shadows. Instead, if I crop each layers first and import them, there's no problem.
    If the higher layer has brush or transparent effects, it becomes worse.
    Any help with this problem?
    Thanks.

    How was the original art created? Was the original RGB or CMYK? What is the resolution of the Photoshop file? Flash only works well with RGB and 72 pixel per inch resolution. If your original art is not set this way, then Flash will attempt to convert it as it imports it. Flash uses the sRGB color space. You'll get the best color translation if your Photoshop file is using this color preference.

  • I am facing a Problem with reading images from database

    Hi everybody..
    any help will be most appreciated, I am facing problem with reading images from database. I am pasting my code... 
                    string connect = "datasource = localhost; port = 3306; username = root; password = ;"; 
                    MySqlConnection conn = new MySqlConnection(connect); // creating connecting string
                    MySqlCommand sda = new MySqlCommand(@"select * from management.add_products ", conn); //creating query
                    MySqlDataReader reader; 
                    try
                        conn.Open(); // Opening Connection
                        reader = sda.ExecuteReader(); // Executing my Query..
                        while (reader.Read())
                            byte[] imgg = (byte[])(reader["Picture"]);
                            if (imgg == null)
                                pc1.Image = null;
                            else
                                MemoryStream mstream = new MemoryStream(imgg);
                                pc1.Image = System.Drawing.Image.FromStream(mstream);
    It says Parameter not Valid... i am reading all the images from database

    I agree with Viorel. You are getting the error because the format of the data is incorrect probably because the data was modify. It may not be the reading of the database the is incorrect, but the application that wrote the data into the database. You need
    to compare the imgg array data with the data before it was written to the database to see if the data matches.  I usually start by comparing the number of bytes which is easier to check then compare the actual to isolate which function is changing the
    byte count.
    An image is binary data.  The standard VS methods for reading and writing data (usually stream classes) default to ASCII encoding which will corrupt binary data.  The solution usually is to use UTF8 encoding instead of the default ascii encoding. 
    Ascii encoding with stream often aligns the data and adds extra null bytes to the end of the data which can produce these type errors.
    jdweng

  • Reading content of a file into an int array

    How do i use FileReader rd = new FileReader(filename) to read the contents into an int array?

    public static int[] parse_file(String filename)
         Vector vec = new Vector();
         int num[];
         num = new num[vec.size()];
         try {
              BufferedReader br = new BufferedReader(new FileReader(filename));
              String line;
              while((line = br.readLine()) != null) {
              vec.add(line);
              for (int i = 0; i < vec.size(); i++) {
              num[i] = (int) vec.get(i);
              System.out.println("Number=" + num);
         catch(IOException e) {
              System.out.println("error");
         return num;
    Maxsum.java:22: cannot resolve symbol
    symbol : class num
    location: class Maxsum
         num = new num[vec.size()];
    ^
    Maxsum.java:30: inconvertible types
    found : java.lang.Object
    required: int
              num[i] = (int) vec.get(i);
    How do i initialize the array?if i do not initialize it, there'll be array not initialized error also..How do i convert the String to int?

  • Problem with reading text from .DOC files through java and POI

    I have used a jar file "poi-scratchpad-3.2-FINAL-20081019.jar" and "poi-3.2-FINAL.jar" to read text from a .DOC file. I used the "getParagraphText()" function of the class "org.apache.poi.hwpf.extractor.WordExtractor" to get the text.
    I am able to get the text in the .DOC file but along with that i am getting the following messages/warnings
    Current policy properties
    *     thread.thread_num_limited: true*
    *     file.write.state: disabled*
    *     net.connect_ex_dom_list:*
    *     mmc.sess_cab_act.block_unsigned: false*
    *     mmc.sess_cab_act.action: validate*
    *     mmc.sess_pe_act.block_blacklisted: false*
    *     mmc.sess_pe_act.block_invalid: true*
    *     jscan.sess_applet_act.stub_out_blocked_applet: true*
    *     file.destructive.in_list:*
    *     jscan.sess_applet_act.block_all: false*
    *     file.write.in_list:*
    *     file.nondestructive.in_list:*
    *     window.num_limited: true*
    *     file.read.state: disabled*
    *     jscan.session.origin_uri: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.jar*
    *     file.nondestructive.state: disabled*
    *     jscan.session.user_ipaddr: 10.136.64.153*
    *     net.connect_other: false*
    *     thread.thread_num_max: 8*
    *     file.destructive.ex_list:*
    *     file.nondestructive.ex_list:*
    *     file.write.ex_list:*
    *     jscan.sess_applet_act.sig_invalid: block*
    *     file.read.in_list:*
    *     mmc.sess_cab_act.block_invalid: true*
    *     jscan.session.policyname: TU1DIERlZmF1bHQgUG9saWN5*
    *     mmc.sess_pe_act.action: validate*
    *     thread.threadgroup_create: false*
    *     net.connect_in_dom_list:*
    *     net.bind_enable: false*
    *     jscan.sess_applet_act.sig_trusted: pass*
    *     jscan.session.user_name: 10.166.64.201*
    *     jscan.session.user_hostname:*
    *     file.read.ex_list:*
    *     jscan.sess_applet_act.sig_blacklisted: block*
    *     jscan.session.daemon_protocol: http*
    *     net.connect_src: true*
    *     jscan.sess_applet_act.unsigned: instrument*
    *     mmc.sess_pe_act.block_unsigned: false*
    *     file.destructive.state: disabled*
    *     mmc.sess_cab_act.block_blacklisted: true*
    *     window.num_max: 5*
    Below the above messages/warnings the data is getting printed. Only the text part of the data is retrieved not the fonts, styles and bullets etc.
    Can anyone explain me why I am getting above warnings and how can I remove them. Is it possible to fetch the text depending on delimiters.
    Thanks in advance,
    Tiijnar
    Edited by: tiijnar on May 21, 2009 2:45 AM

    The jar files which were used are downloaded from http://jarfinder.com. Those jars created the problem of displaying those messages on console. I downloaded APIs from apache.org and used them in my application. Now my application is running good.
    Tiijnar

  • Problem with reading String from Xlsx file.

    Hi! I am trying to read string and numerical data from an xlsx file and trying to display its contents in a word file. I tried converting it to a .lvm file too. On using the "Read From Spreadsheet" tool, I get random characters as output. On using " Read From Measurement File" tool, I am getting an error saying "Error 100 occurred at Read From Measurement File->Untitled 1". What do I do? At the end I need to display the output, row by row, in a Microsoft Word file. I am so lost. Please Help.
    Solved!
    Go to Solution.

    bsvare wrote:
    labview currently does not read directly from an xlsx file. If you convert the xlsx to an xls file first, then you can use the read from spreadsheet tool to load the data from the file.
    Hey, I tried doing that. It still just gave the values 0.00 in all the cells of the indicator array. Plus my file has string in it also. The data type in the spreadsheet was "general". Here in the tool, it is "Double". I changed the tool data type to string and spreadsheet to text but I only got gibbrish for my efforts.
    Thanks anyway!

  • How do I read directly from file into byte array

    I am reading an image from a file into a BuffertedImage then writing it out again into an array of bytes which I store and use later on in the program. Currently Im doing this in two stages is there a way to do it it one go to speed things up.
    try
                //Read File Contents into a Buffered Image
                /** BUG 4705399: There was a problem with some jpegs taking ages to load turns out to be
                 * (at least partially) a problem with non-standard colour models, which is why we set the
                 * destination colour model. The side effect should be standard colour model in subsequent reading.
                BufferedImage bi = null;
                ImageReader ir = null;
                ImageInputStream stream =  ImageIO.createImageInputStream(new File(path));
                final Iterator i = ImageIO.getImageReaders(stream);
                if (i.hasNext())
                    ir = (ImageReader) i.next();
                    ir.setInput(stream);
                    ImageReadParam param = ir.getDefaultReadParam();
                    ImageTypeSpecifier typeToUse = null;
                    for (Iterator i2 = ir.getImageTypes(0); i2.hasNext();)
                        ImageTypeSpecifier type = (ImageTypeSpecifier) i2.next();
                        if (type.getColorModel().getColorSpace().isCS_sRGB())
                            typeToUse = type;
                    if (typeToUse != null)
                        param.setDestinationType(typeToUse);
                    bi = ir.read(0, param);
                    //ir.dispose(); seem to reference this in write
                    //stream.close();
                //Write Buffered Image to Byte ArrayOutput Stream
                if (bi != null)
                    //Convert to byte array
                    final ByteArrayOutputStream output = new ByteArrayOutputStream();
                    //Try and find corresponding writer for reader but if not possible
                    //we use JPG (which is always installed) instead.
                    final ImageWriter iw = ImageIO.getImageWriter(ir);
                    if (iw != null)
                        if (ImageIO.write(bi, ir.getFormatName(), new DataOutputStream(output)) == false)
                            MainWindow.logger.warning("Unable to Write Image");
                    else
                        if (ImageIO.write(bi, "JPG", new DataOutputStream(output)) == false)
                            MainWindow.logger.warning("Warning Unable to Write Image as JPEG");
                    //Add to image list
                    final byte[] imageData = output.toByteArray();
                    Images.addImage(imageData);
                  

    If you don't need to manipulate the image in any way I would suggest you just read the image file directly into a byte array (without ImageReader) and then create the BufferedImage from that byte array.

  • I'm having some problem with Text imported from Motion into FCPro

    Hey Everyone.
    I've got an animation that I created in Motion.
    The format for the timeline in Motion is NTSC DV 4:3
    Final Cut has the same attributes to the sequence.
    I have text on my graphic.... Some of it looks great. Some of it does not.
    You can see it here.
    http://www.drewwfilms.com/Temp/McClure/Graphic.html
    The word "Show" looks terrible, where as the other text looks great.
    I do have a filter on the word show... actually it's not even a filter it's just one of the style parameters which is Outline and Face. The outline attribute has a bit of a blur on it.
    Still i would think this would copy over into final cut without and issue but for some reason it looks really bad.
    Anyone have any ideas on this?
    Thanks.
    -Fraky

    Your problem stems from the bright red on a dark background. It is particularly noticable on text because it is a uniform color.
    You might have other elements in your movies that use this exact shade and it wiil happen there, but it is less noticable because that element consists of multiple tones and is probably moving.
    Very saturated, bright reds always cause problems in video. It is a limitation of the medium.
    If you want to learn more about this facinating subject, the keywords are *Chroma Rise Time*.
    The solution: desaturate and/or lighten the red, change the color completely or live with it.
    Once I render. I get the pixelation.
    Your Motion clip is being rendered to your NTSC DV Sequence setting which is 1:5 compression.
    The problem with the red is only made worse due to this.
    Message was edited to answer newer information from Fraky.

  • Problem with reading data from screen and inserting in table

    hi ther,
    im new to abap-webdyn pro. can anyone suggest how to read data from screen and insert into table when press 'ADD' button.
    i done screen gui , table creation but problems with action. what the content of acton add.
    is ther any link that helps me or tut??
    thankx in advance!
    regards

    Hi,
    Create a context node for the screen fields for which you want to enter the values with cardinality 1.1.....
    Now in the layout of your view bind the screen input fields to that context node(attributes) to the value property of the input fields...
    Now in the action of ADD button....
    --> go the wizard and select the read node button and select the node which you have created it generates the auto code for you.....
    for example if the node is contains aone attribute like MATNR
    reading the node from wizard will generate the code as....
    DATA lo_nd_matnr TYPE REF TO if_wd_context_node.
      DATA lo_el_matnr TYPE REF TO if_wd_context_element.
      DATA ls_matnr TYPE wd_this->element_matnr.
      DATA lv_matnr TYPE wd_this->element_matnr-matnr.
    * navigate from <CONTEXT> to <MATNR> via lead selection
      lo_nd_matnr = wd_context->get_child_node( name = wd_this->wdctx_matnr ).
    * @TODO handle non existant child
    * IF lo_nd_matnr IS INITIAL.
    * ENDIF.
    * get element via lead selection
      lo_el_matnr = lo_nd_matnr->get_element( ).
    * @TODO handle not set lead selection
      IF lo_el_matnr IS INITIAL.
      ENDIF.
    * get single attribute
      lo_el_matnr->get_attribute(
        EXPORTING
          name =  `MATNR`
        IMPORTING
          value = lv_matnr ).
    here the variable lv_matnr will contain the entered value......
    now you can use this value for further process.
    Thanks,
    Shailaja Ainala.

  • Problem with reading NOOK from ADE

    I finally figured out how to authorize my Nook so that I can transfer a library EPUB from ADE to my Nook, but whatever gets copied is not readable on my Nook.  I do not have this problem with my XP computer, which I can no longer go online with, but I have this problem with my 8.1 Windows computer.  Help!

    hi,
    - you can use NFS (if the file is accesible from the XI server)
    via shared folder
    - you can use FTP but your XI server must be able to log on to this FTP server
    - if you use FTP from your local machine the same applies
    (your XI server must be able to log on to this FTP)
    so try checking firewall settings and connection with your admins first to find out if someone
    can log on from the XI server machine to your FTP servers 
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Problem with Data load from file

    Hi,
    if i try to load data from an comma seperated file into oracle, i get an error that the page cannot be displayed, after the dialog where to specify the file and the separation method.
    My Browser does not try long to open the page approx. 1 sec. ...
    Anyone have a Idea about that ?
    P.S I know my englisch is horribile, sorry

    A known bug. See below for a solution to set the timeout. Remember to reboot the PC for the changes take effect.
    See Re: Problem with importing HTML DB applications

  • Problem with downloading data from cube into flatfile

    Hi,
    I am writing a program to download data from cube into flatfile .The program will be run in the background with user has given his selection in a table.the program works fine .The current problem which i am facing is the character length.e.g. Material is 18 ..but in my dynamic internal table it store the value of material with length of 10 character.
    So i am not able to see the output material in correct format.Anybody knows how to change this format.
    thanks in advance
    Yogesh Mali

    Hi Yogesh,
    Theorethically, you can setup the material code length in TX OMSL, which uses the TMCNV table.
    Why don't you change the structure of your internal table changing material fiela length from 10 to 18?
    Best regards,
    Eugene

  • Problems with load DSO from file

    I am working with BI 7.0.
    I am loading data from file to DSO and my problem is that data is not active in my DSO, the data are loaded how New Data and I haven´t the data in query and DSO.
    The settings of my dso are:
    Type: standard
    SIDs Generation upon Activation: X
    Set Quality Status to 'OK' Automatically: X
    Activate Data Automatically: X
    I have created one transformation from datasource to DSO and one DTP that extract from datasource ( No PSA).
    When I execute the DTP there aren´t errors, the status is green and ok but the data is not active.
    If I try activate the data manually the job is launched but the data no active.
    Thanks.

    hai
    Isabel Bautista 
    u r saying the data is not active in dso and also u r loading the data from file directly( no psa).
               i think u know in B.I the data should be in psa then only u can load the data using DTP .so how can u load the data with out data in psa  .i thinks may be because of this u r data is not activating in dso
    if it helps
    assign some points ok

  • Problem with reading ORDImage from DB

    I have table imgtable with
         id number
         Image ordsys.ordImage
    columns and for query
    declare
    src BLOB;
    BEGIN
    Select t.image.getcontent into src from imgtable t where t.id = 1;
    END;
    I receive following erros:
    Select t.image.getcontent into src from imgtable t where t.id = 1;
    ERROR at line 4:
    ORA-06550: line 4, column 12:
    PL/SQL: ORA-00904: "T"."IMAGE"."GETCONTENT": invalid identifier
    ORA-06550: line 4, column 4:
    PL/SQL: SQL Statement ignored
    What is my problem?
    I have Oracle interMedia 9.2.0.1.0 on Linux system, and I veryfied; ORDSYS.ORDImage have getcontent function that return BLOB.

    You should be using t.image.getcontent().....
    declare
    src BLOB;
    BEGIN
    Select t.image.getcontent() into src from imgtable t where t.id = 1;
    END;
    Or better yet (since you can access metadata, like mimetype this way):
    declare
    img ordsys.ordimage;
    src BLOB;
    begin
    select t.image into img from imgtable t where t.id = 1;
    src := img.getContent();
    end;

Maybe you are looking for