I am in daze suddenly by this simple question

warning: [deprecation]readLine() in java.io.DataInputStream has been deprecated.
How to modify it?
Thanks
void inputscan( fileInfo pinfo ) throws IOException
       String linebuffer;
       pinfo.maxLine = 0;
       while ((linebuffer = pinfo.file.readLine()) != null) // this line gets a warning
          storeline( linebuffer, pinfo );
import java.io.*;
/** This is the info kept per-file.     */
class fileInfo {   
  static final int MAXLINECOUNT = 20000;
  DataInputStream file;  /* File handle that is open for read.  */
  public int maxLine;  /* After input done, # lines in file.  */
  node symbol[]; /* The symtab handle of each line. */
  int other[]; /* Map of line# to line# in other file */
                                /* ( -1 means don't-know ).            */
        /* Allocated AFTER the lines are read. */
   * Normal constructor with one filename; file is opened and saved.
  fileInfo( String filename, DataOutputStream  out) {
    symbol = new node [ MAXLINECOUNT+2 ];
    symbol[0].setbufferwriter(out);
    other  = null;    // allocated later!
    try {
      file = new DataInputStream(
        new FileInputStream( filename));
    } catch (IOException e) {
        System.err.println("Diff can't read file " +
        filename );
        System.err.println("Error Exception was:" + e );
        System.exit(1);
class node{                       /* the tree is made up of these nodes */
  node pleft, pright;
  int linenum;
  static final int freshnode = 0,
  oldonce = 1, newonce = 2, bothonce = 3, other = 4;
  static DataOutputStream out;
  int /* enum linestates */ linestate;
  String line;
  static node panchor = null;    /* symtab is a tree hung from this */
   * Construct a new symbol table node and fill in its fields.
   * @param        string  A line of the text file
  node( String pline )
       pleft = pright = null;
       linestate = freshnode;
       /* linenum field is not always valid */    
       line = pline;
   * matchsymbol       Searches tree for a match to the line.
   * @param  String  pline, a line of text
   * If node's linestate == freshnode, then created the node.
  static void setbufferwriter(DataOutputStream  x)
       out = x;
  static node matchsymbol( String pline )
       int comparison;
       node pnode = panchor;
       if ( panchor == null ) return panchor = new node( pline);
       for(;;) {
      comparison = pnode.line.compareTo(pline);
      if ( comparison == 0 ) return pnode;          /* found */
      if ( comparison < 0 ) {
           if ( pnode.pleft == null ) {
          pnode.pleft = new node( pline);
          return pnode.pleft;
           pnode = pnode.pleft;
      if ( comparison > 0 ) {
           if ( pnode.pright == null ) {
          pnode.pright = new node( pline);
          return pnode.pright;
           pnode = pnode.pright;
       /* NOTE: There are return stmts, so control does not get here. */
   * addSymbol(String pline) - Saves line into the symbol table.
   * Returns a handle to the symtab entry for that unique line.
   * If inoldfile nonzero, then linenum is remembered.
  static node addSymbol( String pline, boolean inoldfile, int linenum )
    node pnode;
    pnode = matchsymbol( pline );  /* find the node in the tree */
    if ( pnode.linestate == freshnode ) {
      pnode.linestate = inoldfile ? oldonce : newonce;
    } else {
      if (( pnode.linestate == oldonce && !inoldfile ) ||
          ( pnode.linestate == newonce &&  inoldfile ))
           pnode.linestate = bothonce;
      else pnode.linestate = other;
    if (inoldfile) pnode.linenum = linenum;
    return pnode;
  }

If you read the docs for that method, you'll see this:
As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:
DataInputStream d = new DataInputStream(in);
with:
BufferedReader d
= new BufferedReader(new InputStreamReader(in));

Similar Messages

  • Can't anyone answer this simple question?

    Guys,I want to know whether a GUI which is made using Swing can write files to disk,or ,in another way--does Swing support writing files to disk?(This is becoz applets do not support this feature)
    Thannks in advance,
    Avichal167

    One thing to note...
    Because the previous example is simple, I handled all the File IO operations in the same class as the GUI ...
    You can how ever have the File IO done in a different class and tie it in to your GUI class...
    Example... GUISample.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GUISample extends JFrame implements ActionListener{
            private JTextArea jtxArea;
            private JButton jbtn;
            private String[] bText = {"Read","Write"};
            private boolean bState = true;
            private FileHandler handler;
         public GUISample(){
                 super("GUI Sample");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLayout(new BorderLayout());
              jtxArea = new JTextArea(15,20);
              jtxArea.setEditable(true);
              jbtn = new JButton(bText[0]);
              jbtn.addActionListener(this);
              getContentPane().add(jtxArea,BorderLayout.CENTER);
              getContentPane().add(jbtn,BorderLayout.SOUTH);
              pack();
              setVisible(true);
              handler = new FileHandler(); // instantiates FileHandler
         /* both method from FileHandler return Strings to be displayed in the JTextArea */
         public void readAndDisplay(){
              jtxArea.setText(handler.readTheFile()); // calls method from FileHandler
         public void writeToFile(){
              jtxArea.setText(handler.writeTheFile(jtxArea.getText())); // calls method from FileHandler
         public void actionPerformed(ActionEvent ae){
                if ((ae.getSource() == jbtn)&&(bState)){
                      bState = false;
                      jbtn.setText(bText[1]);
                      readAndDisplay();
                 else{
                           bState = true;
                           jbtn.setText(bText[0]);
                           writeToFile();
         public static void main(String[] args){
                 GUISample gspl = new GUISample();
    }Example... FileHandler.java
    import java.io.*;
    public class FileHandler {
    private String theData;
    public String readTheFile(){ // reads and returns data or message
             try{
                 File afile = new File("test.txt");
                     FileInputStream fis = new FileInputStream(afile);
                      try{
                           byte[] strBuff = new byte[(int)afile.length()];
                           fis.read(strBuff);
                           try{
                                theData = new String(strBuff);
                                fis.close();
                           }catch(NullPointerException npe){theData = "Null Pointer Exception";}
                       }catch (IOException ioe){theData = "IO Exception";}
               }catch (FileNotFoundException fnfe){ theData = "File Not Found";}
         return theData;
         public String writeTheFile(String data){ // writes and returns a message
             try{
                 File afile = new File("test.txt");
                     FileOutputStream fos = new FileOutputStream(afile);
                   try{
                           try{
                           fos.write(data.getBytes());
                           fos.close();
                           theData = "File Saved";
                    }catch(NullPointerException npe){theData = "Null Pointer Exception";}
                       }catch (IOException ioe){theData = "IO Exception";}
               }catch (FileNotFoundException fnfe){theData = "File Not Found";}
               return theData;
    }and of course you can use the same Test.txt file...
    As you can see from this example, I have one class create and handle the GUI and the second class handles all the File IO operations...
    So to better answer your first question, Swing and AWT and Applets can be used to create GUIs... and as far as File IO, all three can have code or be couples with a class that does File IO operations...
    The only restriction is with Applets where by default the SecurityMananger does not allow File IO operations...
    Notice the word "default", this means Applets are capable of doing File IO, if you do some extra coding and policy work... ( my terminology may be off on this)
    But as stated earlier, I am not well versed enough in Applets to give you assistance in creating a Signed Applet that can... soon I will, just not at this time...
    - MaxxDmg...
    - ' He who never sleeps... '

  • Someone PLEASE answer this simple question

    what are the technical specs on the line input for the audigy 2 zs? high/low impedance? voltage level? anything please, creative has no really DETAILED specs on their products.
    thanks
    L_E

    Reasonably sure it's high impedance, designed for 2v peak-peak (ie. -v peak to +v peak), with the playback volume control an analog attenuator which affects recording, and the recording volume control digital with a x2 multiplier (i.e. 0dB is approx at 50% position).
    One thing this means is that a "too-hot" signal can be attenuated to match the 2Vp-p ADC range to prevent digital clipping of it.
    Yes, CL has a reluctance to say more than necessary about internal details.
    -Dave
    [email protected]

  • Please answer this simple question: it plays an important role

    How to write query to retreive the latest record by using PN-BEGDA , PN-ENDDA, SYDATUM,.
    I know using RP-PROVIDE.......other method using query i require
    it is urgent

    Hi Ramana,
                     Try this one this will give the latest record in terms of time ok. sy-uzeit : display the current time ok..
    data: time like sy-uzeit.
    time = sy-uzeit + 80.
    Here 80 is SECONDS OK..
    select * from PAnnnn where begda = time.
    Reward points if helpful
    Kiran Kumar.G.A

  • I'm confused answer this simple question please...

    I have askew at least 10 people on here "when you get BT Infinity will they install a phone line for free?" And everyone has said yes is this true? Because I signed up today and they said a extension is free but and phone line isn't or is she wrong?

    If you have no BT line whatsoever a phone line would be installed free with an 18 month contract. If you have an existing BT line then BT would put infinity on that line.
    You could have BT set up a free new line for infinity and keep your existing line as well. But that would be strange as it would mean your paying for line rental twice.
    So best to ask BT to put infinity on your existing line. They won't provide an extension, but they can provide a long Ethernet cable if you want the hub in another room

  • Should be the bluetoot symbol grayed out when the bluetooth is turned "ON"or it should be highlighted in white like rest of the active symbols are? Please unswer this simple question clearly. Thank you.

    My blutooth symbol on the new i-Pod 2 is grayed out when the option is turned "ON". Shouldn't be highlighted white like the rest of the symbols are?

    when blue tooth is turned off in settings, the symbol does not show at all.  when BT is turned on in settings, but there is no connected device, it will show the symbol gryed out.  When BT is on, and connected to an active device, it will show as bright white.

  • Methods//simple question

    I need to add a method text ValueChanged to my program and am not sure how can anyone help me with this simple question?

    Can you be a little more specific?
    Do you not know how to write a method or do you need to know how to be notified when something happens to your text?

  • This might be a simple question.   On those sites that do not differentiate between models when on the internet I.e. Facebook when after your comment and you cannot hit "enter" on an iPad for examp. And speed is slow to connect.  What is = to post?

    This might be a simple question. On those sites that do not differentiate between CRT, laptop, tablet etc. such as an iPad Mini and using the Facebook site fir example when going to post a comment and you do not have a enter button on the IPad and the speed is slow how do you get your comments to post if we do not have a enter button? 
    <Email Edited By Host>

    I don't have facebook so I cannot answer but for your personal security, I have asked the hosts to remove your e-mail address.   It is very unwise to publish this.

  • Simple question:  I want to use iCloud as a back up disk for my documents folder.  How can I do this?  If I cannot do this, why am I paying for access to "the cloud?"

    Simple question:  I want to use iCloud as a back up disk for my documents folder.  How can I do this?  If I cannot do this, why am I paying for access to "the cloud?"

    iCloud does not provide general file storage or backup, so you cannot back up your Documents folder using it. You will need to find a third-party alternative - this page examines some options (some are free):
    http://rfwilmut.net/missing3
    iCloud at basic level, with 5GB is storage, is free: you only pay anything if you want to increase the storage space.

  • Is there a way to create a schema for this simple XML?

    Hi! A simple question. Suppose we have a XML that looks like that (simplified)
    <documents>
      <total>2</total>
      <doc_1>
        <name>My document</name>
        <code>1234</code>
      </doc_1>
      <doc_2>
        <name>Another document</name>
        <code>5678</code>
      </doc_2>
    </documents>In this simple example, if the tag <total> had a numer of three, there would be a <doc_3> tag.
    Is it posible to create a XSD to this XML? And is it posible for JAXB to process that XSD?
    Thank you in advance

    There are some tools around to generate XML Schemas from instance documents, but I don't know if they are too smart. For example, XMLSPY created the following Schema from your sample:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:element name="code">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                        <xs:enumeration value="1234"/>
                        <xs:enumeration value="5678"/>
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="doc_1">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="name"/>
                        <xs:element ref="code"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="doc_2">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="name"/>
                        <xs:element ref="code"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="documents">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="total"/>
                        <xs:element ref="doc_1"/>
                        <xs:element ref="doc_2"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="name">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                        <xs:enumeration value="Another document"/>
                        <xs:enumeration value="My document"/>
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="total">
              <xs:simpleType>
                   <xs:restriction base="xs:byte">
                        <xs:enumeration value="2"/>
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
    </xs:schema>XMLSPY has done its best but this Schema could certainly be cleaned up and made more efficient. If your instance documents aren't going to be too complex, it's probably best to have a tool like XMLSPY start you off, then you can go in by hand.
    But, once you have the Schema in hand, you're ready to get started with JAXB.

  • I suddenly have this error message on FireFoxthis message pops up: "Could not initialize the application's security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no re

    I suddenly encounter this error message from Fire Fox.
    Could not initialize the application's security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no read/write restrictions and your hard disk is not full or close to full. It is recommended that you exit the application and fix the problem. If you continue to use this session, you might see incorrect application behaviour when accessing security features.
    I uninstalled the browser and download a new version but it does not resolve the issue.
    I know my hard disc has ample space. I do NOT know where to find the Profile directory to fix the read restriction box.
    == This happened ==
    Every time Firefox opened
    == After something about security add-on of Norton pop up by itself. ==
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; MSN Optimized;US)

    This link shows things to check - https://support.mozilla.com/kb/Could+not+initialize+the+browser+security+component

  • What's wrong with this simple code?

    What's wrong with this simple code? Complier points out that
    1. a '{' is expected at line6;
    2. Statement expected at the line which PI is declared;
    3. Type expected at "System.out.println("Demostrating PI");"
    However, I can't figure out them. Please help. Thanks.
    Here is the code:
    import java.util.*;
    public class DebugTwo3
    // This class demonstrates some math methods
    public static void main(String args[])
              public static final double PI = 3.14159;
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);

    Change your code to this:
    import java.util.*;
    public class DebugTwo3
         public static final double PI = 3.14159;
         public static void main(String args[])
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);
    Klint

  • What's wrong with this simple method

    i'm having compile troubles with this simple method, and i think it's got to be something in my syntax.
    public String setTime()
    String timeString = new String("The time is " + getHours() + ":" + getMinutes() + ":" + getSeconds() + " " + getIsAM());
    return timeString;
    this simple method calls the get methods for hours, minutes, seconds, and isAM. the compiler tells me i need another ) right before getSeconds(), but i don't believe it. i know this is a simple one, but i could use the advice.
    thanks.

    Hi,
    I was able to compile this method , it gave no error

  • Hi can someone keep this simple for me! my iPhone is due for a renewal. but my old laptop that it is backed up to no longer works! how do i go about saving all my songs pics etc to a new laptop without losing anything? please help!!!

    hi can someone keep this simple for me! my iPhone is due for a renewal. but my old laptop that it is backed up to no longer works! how do i go about saving all my songs pics etc to a new laptop without losing anything? please help!!!

                     Syncing to a "New" Computer or replacing a "crashed" Hard Drive

  • Trying to optimize this simple query

    Hi,
    I am trying to optimize this simple query but the two methods I am trying actually make things worse.
    The original query is:
    SELECT customer_number, customer_name
    FROM bsc_pdt_account_mv
    where rownum <= 100
    AND Upper(customer_name) like '%SP%'
    AND customer_id IN
    SELECT cust_id FROM bsc_pdt_assoc_sales_force_mv
    WHERE area_identifier IN (
    SELECT area_identifier FROM bsc_pdt_assoc_sales_force_mv
    WHERE ad_identifier = '90004918' or rm_identifier = '90004918' or tm_identifier = '90004918'
    The result set of this query returns me the first 100 rows in 88 seconds and they are all distinct by default (don't know why they are distinct).
    My first attempt was to try to use table joins instead of the IN conditions:
    SELECT
    distinct -- A: I need to use distinct now
    customer_number, customer_name
    FROM bsc_pdt_account_mv pdt,
    bsc_pdt_assoc_sales_force_mv asf,
    SELECT distinct area_identifier FROM bsc_pdt_assoc_sales_force_mv
    WHERE ad_identifier = '90004918' or rm_identifier = '90004918' or tm_identifier = '90004918'
    ) area
    where
    area.area_identifier = asf.area_identifier
    AND asf.cust_id = pdt.customer_id
    AND Upper(customer_name) like '%SP%'
    AND rownum <= 100 -- B: strange when I comment this out
    order by 1
    I dont understand two things with this query. First issue, I now need to put in the distinct because the result set is not distinct by default. Second issue (very strange), when I put the rownum condition (<100) I get two rows in 1.5 seconds. If I remove the condition, I get 354 rows (whole result set) in 326 seconds.
    My second attempt was to use EXISTS instead of IN:
    SELECT
    customer_number, customer_name
    FROM bsc_pdt_account_mv pdt
    where Upper(customer_name) like '%SP%'
    AND rownum <= 100
    AND EXISTS
    select 1 from
    bsc_pdt_assoc_sales_force_mv asf,
    SELECT distinct area_identifier FROM bsc_pdt_assoc_sales_force_mv
    WHERE ad_identifier = '90004918' or rm_identifier = '90004918' or tm_identifier = '90004918'
    ) area
    where
    area.area_identifier = asf.area_identifier
    AND asf.cust_id = pdt.customer_id
    This query returns a similar distinct result set as teh original one but takes pretty much the same time (87 seconds).

    The query below hangs when run in TOAD or PL/SQL Dev. I noticed there is no rows returned from the inner table for this condition.
    SELECT customer_number, customer_name
    FROM
    bsc_pdt_account_mv pdt_account
    where rownum <= 100
    AND exists (
    SELECT pdt_sales_force.cust_id
    FROM bsc_pdt_assoc_sales_force_mv pdt_sales_force
    WHERE pdt_account.customer_id = pdt_sales_force.cust_id
    AND (pdt_sales_force.rm_identifier = '90007761' or pdt_sales_force.tm_identifier = '90007761') )
    ORDER BY customer_name
    -- No rows returned by this query
    SELECT pdt_sales_force.cust_id
    FROM bsc_pdt_assoc_sales_force_mv pdt_sales_force
    WHERE pdt_sales_force.rm_identifier = '90007761' or pdt_sales_force.tm_identifier = '90007761'

Maybe you are looking for

  • Simultaneous data activation in cube - request for reporting available

    Hi, I'm on BW 3.5. I am loading several million records to a cube, processing is to PSA first and subsequently to data target. I have broken the load up into 4 separate loads to prevent caches from filling up and causing huge performance issues. When

  • Pages wont load Win 8.1

    I have updated to win 8.1 and find that some pages just wont load, sometimes theirs a big lag. eg This page can't be displayed Make sure the web address http://www.superrugby.co.nz is correct. Look for the page with your search engine. Refresh the pa

  • HP Photosmart Studio

    How do you delete pictures from HP Photosmart Studio?  I am working with old system Mac OS X 10.4.11 and old camera Photosmart M547.  Thx!

  • How to view the directory structure of JS sources in debugger?

    I'm a web developer and want to use Firefox, but am used to using Chrome for debugging. In Chrome debugging tool (hit F12 -> click 'sources' tab in top of the web dev window), you can clearly see the entire Javascript directory structure of the site

  • InDesign Crashing when trying to print or make a pdf.

    I am currently on using CC/CS 7 on a PC and I have a document that crashes InDesign everytime I go to print or make a pdf.  The document has a lot of photos in it, is roughly 70 pages with linked text and the file size is around 750 meg. Here is the