Problem importing classes

Hi, I've doing a simple program to read a file and output its content by using BufferedReader and readLine() methods. My executing program is "TestProgram.java" and it imports the class "InputFileReader" to use. I have all the files in the same directory C:\j2SDK1.4_0\bin.
When I compile "TestProgram.java", it returns the error message : Cannot resolve symbol. Symbol : variable InputLineReader.
Can someone help me with the problem? The 2 codes are provided below.
// InputLineReader.java
package bin;
import java.io.*;
import java.util.*;
public class InputLineReader
     public static String lineRead (BufferedReader buff)
          String line = null;
          try {
          line = buff.readLine();
               } catch(IOException e) {
          System.out.println("IO Error");
          return line;
// TestProgram.java
package bin;
import java.io.*;
import java.util.*;
import bin.*;
public final class TestProgram {
     public static void main (String[] args) {
          FileReader file = new FileReader ("strtestdata1.txt");
          BufferedReader buff = new BufferedReader(file);
          String output = null;
          output = InputLineReader.line;
          System.out.println(output);

I Dont Know Exactly Why The Problem Is. .......
Anyway here is class I have written that works ...
It reads ffrom a while and writes to another file ..
I hope you can get some useful info from it
import java.io.*;
// This class Attempts to read from a file containing text, line by line and
// copy the contents to a new file ...................
public class ReadAndWrite {
    // initialising variables
    private String textLine;
    int count;
    private LineNumberReader lineReader;
    private BufferedReader bReader;
    private BufferedWriter bWriter1, bWriter2;
    private File readFile, writeFile1, writeFile2;
    // constructor
    public ReadAndWrite(String pathRead, String pathWrite1, String pathWrite2) {
        try{
            readFile   = new File(pathRead);
            writeFile1 = new File(pathWrite1);
            writeFile2 = new File(pathWrite2);
            bReader    = new BufferedReader(new FileReader(readFile));
            lineReader = new LineNumberReader(bReader);
            bWriter1 = new BufferedWriter(new FileWriter(writeFile1));
            bWriter2 = new BufferedWriter(new FileWriter(writeFile2));
        }  catch (IOException e2) {
            // Catch any other IO exceptions.
            e2.printStackTrace();
    // method to read text line by line from a given file
    public String readFile()  {
        try{
            textLine = lineReader.readLine(); // reads one line and keeeps in buffer
        }  catch (FileNotFoundException e1) {
            // If this file does not exist
            System.err.println("File not found: " + readFile);
        } catch (IOException e2) {
            // Catch any other IO exceptions.
            e2.printStackTrace();
        return textLine;
    // method that writes the text to a new file line by line
    public void  writeFile(String textLine, int count1) {
        try{
            // prints the numbered text lines to the standard output
            System.out.println(count1 + "  " + textLine);
            // writes the numbered text lines to a new file
            bWriter1.write(lineReader.getLineNumber() + "  " + textLine); // text file
            bWriter1.newLine();
            bWriter2.write(lineReader.getLineNumber() + "  " + textLine); // word file
            bWriter2.newLine();
        } catch (IOException e2) {
            // Catch any other IO exceptions.
            e2.printStackTrace();
    // method calls readFile() and writeFile()
    public void process() {
        try{
            count = 1;
            // loop to call read and write methods
            // checks for text in the file = null
            do {
                readFile();
                if (textLine != null){
                    writeFile(textLine, count);
                    count ++;
            while (textLine != null);
            // closing all open streams when they are no longer needed
            lineReader.close();
            bWriter1.close();
            bWriter2.close();
        } catch (IOException e2) {
            // Catch any other IO exceptions.
            e2.printStackTrace();
}

Similar Messages

  • Problem importing classes and beans

    Hey there. Im having one major fustrating problem! When I code supporting classes and beans for my JSPs I get a code 500 internal server error when trying to import (via <%@ page import="class" %> and <jsp:useBean/>) Im storing my classes and beans in the WEB-INF folder and the calling JSPs are located in /ROOT/tests/8/jsp.jsp. Im using the following to import a class or bean:
    <%@ import="aClass" %>
    Seen as tho its in the WEB-INF folder I won't have to explicitly refer to where the class is located, just the class name.
    I never had this problem when I was using my hosting service. Its only on my localhost server in which I get the Internal Server error.
    Help appreciated, thx.
    PS: Im quite new to JSP/Java Servlet.

    import (via <%@ page import="class" %> and
    <jsp:useBean/>) Im storing my classes and beans in the
    WEB-INF folder try put your class file in WEB-INF/classes.
    or first put bean in the package, like WEB-INF/classes/packagename/beanclass
    in jsp page:
    <jsp:useBean id="Mybean" class="packagename.beanclass" scope="request" />
    Question: is /ROOT a context entry in your server.xml?
    Which JSP Container (version) you use? Maybe your localhost server's set up is different with your hosting.

  • Problems importing class

    the code is fine.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.swing.*;
    import java.TicTacDlg;
    Error i get is:
    TTacToe.java:12: '.' expected
    import TicTacDlg;
    ^
    1 error
    TicTacDlg.java is in DIR is in '/root/java' along with the rest of the classes.
    I have tried setting CLASSPATH to above path and '/usr/java/j2sdk1.4.0/lib/tlib/tools.jar'
    Is it correct to set CLASSPATH to tools.jar, as u do in windows?
    I'm using the beta version of java 2 SDK 1.4 standard addition
    I'm

    Sorry, the statement:
    import .java.TicTacDlg was actually a typo made when typing this message and is actually:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.swing.*;
    import TicTacDlg;
    Also as i'm have not done any java since early 1999 in UNI. I have noticed newly introduced words i.e "package" please explain.
    Is a package just another word for classes, such as TicTacDlg.java as i have defined.
    In those days we were using JSDK 1.2 and did not use the word package. Please give example if can.
    Thanks

  • Inner class vs. imported class

    Hi everyone,
    I have entitiy beans created for a client's web app I'd like to use in the
    web service using WebLogic Workshop 7.0. Say the classes are imported like
    this in the services:
    import com.hoike.clientname.ap.bean.Invoice
    import com.hoike.clientname.ap.bean.Vendor
    Instances of these classes are used in callback methods and some of the
    service methods.
    When I generate the CTRL file, it actually adds those imported classes as
    inner class of the service defined.
    The problem is that when I try to used these services from another service,
    I cannot use the imported classes (as Invoice or Vendor), but instead I have
    to use the inner class (InvoiceService.Invoice or VendorService.Vendor)
    Does WebLogic Workshop 7.0 only allow you to use inner classes? Is there a
    way to use custom classes as method parameters?
    Thanks in advance!
    Makoto

    how do you declare your inner class?
    Is it (public)
    public static class MyInnerClassor (private)
    private static class MyInnerClassor (package)
    static class MyInnerClassor (protected)
    protected static class MyInnerClassTry to change the way you declare the inner class. Use protected or package or public instead.

  • Hi, new to 3D, doubt in importing class

    hi all,
    i m new to JAVA 3D, i currrently hv a simple example source which i try to compile it, it just can't, saying that class not found, but i m sure i hv download and install the JAVA 3D for DirectX 1.3.1, also i hv the following code
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Label;
    import java.awt.GraphicsConfiguration;
    // below having importing class problem
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;can anyone guide me, thank you

    That is the way I understand it. Here is the information from the documentation.
    The version of the Export utility must be equal to the version of either the source or target database, whichever is earlier.
    For example, to create an export file for an import into a later release database, use a version of the Export utility that equals the source database. Conversely, to create an export file for an import into an earlier release database, use a version of the Export utility that equals the version of the target database.
    In general, you can use the Export utility from any Oracle8 release to export from an Oracle9i server and create an Oracle8 export file.
    Then further down is this handy table:
    Table 21-5 Using Different Releases of Export and Import
    Export from Import to Use Export Release Use Import Release
    10.1.0 9.0.2 9.0.2 9.0.2
    So, that is the way I understand this. I have not done this, but this is how I undertand it to work.
    Please correct me if I am wrong.
    Thanks
    Dean

  • Importing classes confusion AS3

    I must admit, I don't know Actionscript 3.0 extremely well but I know my way around it and am able to get by as a designer.
    I'm just wondering if classes should ALWAYS be imported. The reason I ask is because sometimes I don't import classes but my Actionscript still works without any problems.
    Just wondering if anyone could shed some light on this please?
    Thanks

    Are you using custom classes? If so then all of the ones you use will be required.
    So suppose you have in your code:
    var myInstance:SomeClass = new SomeClass();
    Then at the top you should add
    import com.mydomain.somePackage.SomeClass;
    Or if you are using packages like TweenLite or such. Even if you have added that to your classpath and it works without the import statement, it would be a surprise if you move it to another machine that doesn't have that installed.
    And of course the best way to find out is to have a problem where something goes wrong. That is really all that separates the noobs from the "pros" -- we have made a lot more mistakes than you've even thought of yet!

  • Problems importing 3D layers from Photoshop

    Hi, I am a public school teacher in Australia and we have a site licence for the Adobe Master Collection CS4 at school. I am having some problems importing 3D layers into After Effects from Photoshop.
    Firstly, I have a computer in my office with exactly the same software, installed from the same source as the computers in my class room. They are all running Google SketchUp 8, Photoshop Extended CS4 and After Effects CS4.
    In my office I am able to export a 3D model from SketchUp using the KMZ format and open it using Photoshop. I can then save the file as a PSD file. I can't attach the file here as it is just over 2mb. When I import it into After Effects using the Photoshop Live 3D option I can rotate the model as normal and the elements appear as shown below.
    When I try the exact same exercise in my class room (where the computers are all running exactly the same versions of Photoshop Extended CS4 and After Effects CS4) the model is imported as a 2D image with no ability to rotate or interact with the model. It appears that the camera and controller layers are missing from the timeline as well as the Solids folder from the Project pane as shown below.
    I have been trying to figure out the difference for most of the day today and so far I cannot find any reason for this to occur, neither can I find anyone with a similar problem who has solved it.
    Any help would be greatly appreciated,
    Mr Merrick

    PS Live 3D requires hardware acceleration to work properly, that is in terms of OpenGL support being available in Photoshop on the machines in question. If that's not the case, the importer component won't function either as it uses the same routines.
    Mylenium

  • Import class file in default package (netbeans) into my jsp

    Hello all I have created a class file in the default package under Source Files in the netbeans 5 ide.
    I am having a problem importing that class file into my jsp(which resides in the Web Pages directory .
    I tried the following:
    <jsp:useBean id="dial" class="Test" scope="session" />
    my class file is Test.java
    Any help or explanation would be greatly appreciated.
    TIA!

    Will not work. Classes have to be defined in a package, the default package just wont do.
    ram.

  • I am having problems importing from a DVD or a CD to my Ipod nano via windows 8.  I initially set everything up on a computer with windows 7, and authorized the windows 8 computer as well.  Howevre, the oly thing that comes up on windows 8 is my purchases

    I am having problems importing to my Ipod nano via windows 8.  I usually do this from a windows 7 computer and have had no problems; hoever in windows 8 I can only see items purchased in the Itunes store.  I do not have access to my entire library, which includes song uploaded from CDs and some videos.  As a result, I'm having problems uploading any new items from CDs or DVDs.  The computer with windows 8 is an authorized computer, so I don't understand why I'm having the problem.

        Hello APVzW, we absolutely want the best path to resolution. My apologies for multiple attempts of replacing the device. We'd like to verify the order information and see if we can locate the tracking number. Please send a direct message with the order number so we can dive deeper. Here's steps to send a direct message: http://vz.to/1b8XnPy We look forward to hearing from you soon.
    WiltonA_VZW
    VZW Support
    Follow us on twitter @VZWSupport

  • Problem importing from JVC MG 155 (videcam with hard disk drive)

    I had a problem importing video from my videocam Jvc MG 155.
    I tried when there was only few record in the videocam and everything gone right.
    Otried when there were 520 movies and over 4 hour of video (I went to holiday and made also underwater movies) and the program crach before importing the movies.
    I can import the moviesw only via firewire but in this way i import in DV mode (so I have near 60 gigabytes occupied by that movies insted of the original size in the hdd of the camera of 18 giga).
    Someone have a solution?
    If I import by firewire I reach the same quality (the camera record directly in mpeg 2 and via firewire I import in dv way)?
    Any idea?
    Jvc don't support mac because they don't give you software compatible (the cd inside is win only).

    You are right.
    But the first time I imported with imovie 08 (the time when there was only few movies on the camera and everything gone right and the program don't crash) i notice that the program imported the movies in compress format (mpeg2) and the size was the same of the videocamera (more or less ..but I'm sure it's not in DV format).
    Maybe the prgram crash because of the hight number of the miniature it must generate to let me choose witch I want import.
    Certantly Apple mus resolve this bug because the model of this videocamera is one of the fews they assure like compatible directly with imovie 08.

  • Problems importing connections from a SAN directory

    Is anybody having a problem importing connections from a directory that's on a SAN?
    My network is setup so that the Application Data directory is out on a SAN and when SQL Developer opens up the file dialog, current directory is listed as C:\ and entry in the file name field is file://<server>/<path to my stuff>/Application Data/SQL Developer/. This looks fine but when I click on the "Open" button to get the directory listing, an error dialog pops up with the following message:
    The directory C:\file:\<server>\<path to my stuff>\Application Data\SQL Developer is not accessible. Please select a different directory.
    When I change the current directory to the drive that maps the SAN location, I get the same message only with C: replaced with another drive letter.
    If I had to guess, the dialog is not processing the file:// protocol indicator properly before it attempts to get the directory listing. Does anyone have a work around?

    Other users also had problems with network shares, so you're right that might very well be the cause of your problems.
    As workaround, try mapping the settings folder to a local drive. Add this to \sqldeveloper\bin\sqldeveloper.conf:
    AddVMOption -Dide.user.dir=C:\sqldeveloperHope that helps,
    K.

  • Importing Class

    I was reading the tutorial on importing class's. This is what
    I read
    Importing classes
    To reference a class in another script, you must prefix the
    class name with the class's package path. The combination of a
    class's name and its package path is the class's fully qualified
    class name. If a class resides in a top-level classpath
    directory--not in a subdirectory in the classpath directory--then
    its fully qualified class name is its class name.
    To specify package paths, use dot (.) notation to separate
    package directory names. Package paths are hierarchical, where each
    dot represents a nested directory. For example, suppose you create
    a class named Data that resides in a com/xyzzycorporation/ package
    in your classpath. To create an instance of that class, you could
    specify the fully qualified class name, as shown in the following
    example:
    var dataInstance = new com.xyzzycorporation.Data();
    My Question is about com/xyzzycorporation/ . would the full
    class parth be c:/com/xyzzycorporation/ . Why do they never state
    the drive letter when teaching about directories.

    Because there is no need. you don't need to reference the
    drive letter.
    Here's the basic jist of what they are saying....
    Single Class File...
    If you create your own custom class and want to use it in
    your flash file, save it into the same directory as the fla file
    and call the classes constructor. By default flash will look inside
    the folder where the fla resides in for the class files if it
    cannot find it inside the default directory.
    Multiple Class Files - 1 Project (often referred to as
    packages)
    Use your qualified domain name but backwards.....
    my domain is www.sd-dezign.com so if I was going to include a
    package of utility class files in my document I would do the
    following
    Create a folder in the same folder with my fla name it com
    and inside that a folder called sddezign and inside that utils and
    all my as files would be in there...the folder structure might look
    like this....
    myfile.fla
    com
    >sddezign
    >>utils
    >>>box.as
    >>>circle.as
    To call the constructor for each class, I have two options.
    The first which is by far the easiest looks like this
    In whatever frame you need to call that class constructor
    include "com.sddezign.utils.*";
    var myBox:Box = new Box();
    The second method requires more typing and can get tedious
    var myBox = new com.sddezign.utils.Box();
    Hope this helps you a bit better.

  • Not allowed to import classes without package names?

    Hi,
    I have a few questions on Packages and importing?
    1. Is the following true that it is illegal to import classes in the same package as the current class, will this cause a comilation error? If this is the case where in the Java Language specification is this actually written as I could not find it?
    2. This has probably been answered by question 1 but if I have 2 classes in the same package and if I import 1 of the classes into the other class, is it illegal to import it by just using the class name and not the package name as well, ie
    if the package name is ie.tcd
    and the 2 class names are exp1.class and exp2.class, can I do this in class 2
    package ie.tcd;
    import exp1;
    public class exp2 {
    3. Is it illegal to import classes that are not explicitly part of any package or must a class be part of a package to be imported. I read somewhere that while this was always illegal it is only after jdk 1.4.2 that this is being enforced? If this is the case where in the Java Language specification is this actually written as I could not find it either?
    Thanks very much for any help,
    John

    Was just also wondering, 1 other thing, I am looking
    at someone elses code they have 2 classes (Class A
    and Class B) in the same package (pkg). The person
    imports class A into B:
    package pkg;
    import A;
    public class B {
    Is this legal code (or was it ever)?Not if A is really in pkg.A. If there is an A in the unnamed package it was legal, or at least it was understood by the compiler, and now it isn't (to both).
    Can you import or is there a point in importing a class in the same
    package?Only by naming the package in the import statement. If the current and the import statement are in the same package the import is redundant.
    If there is a point would you import just be
    using the class name (this would be illegal after jdk
    1.4) or should you use the whole package name even
    though it is in the package anyways?As I understand it you must always use the whole package name in imports.

  • Problems importing videos recorded from my iPhone 3GS to iPhoto

    I am having problems importing any videos recorded from my iPhone 3GS onto iPhoto. iPhoto keep giving me the following error:
    "Error downloading Image. iPhoto cannot import your photos because there was a problem downloading an image."
    If anyone else is having the same problem, please advise on how to fix.
    Thanks,

    I am having the same problem...
    and Image Capture ( didn't know we would normally be able to use it, but you can) also give an error
    "Import Error"
    Now I have used "ITimelapse pro" to transfer some timelapse movies (about 3 that are about 30 to 60 seconds long) that I made to the phone's photo library.. and I has a very long video that I mistakenly made - (15 minutes long or so) and I "trimmed" it to be a few minutes long. -- and used "JotNot" to send a photo to the photo library... otherwise I have only some regular photos (about 40 ) and about 2 regular videos in the library.
    so any suggestions... ( I am emailing all that I can to myself ... maybe ridding everything will help)

  • Compilation Error for import classes not found in generated Proxy Class

    Hi,
    We are generating java classes for the COM dll using JCOM com2java compiler.
    We are getting a compilation error for import class not found when compiling the
    generated Proxy java source code. It can't find the com.bea.jcom.Dispatch class that
    the generated Proxy java source code extends. It also can't find com.bea.jcom.Variant
    or com.bea.jcom.Param. These are interfaces or data types or classes used by COM
    library.
    I added weblogic.jar to my class path and the only Dispatch class i found inside
    the weblogic.jar is com.linar.jintegra.Dispatch;
    We have com objects for which we want to develop an EJB client to interface with
    the COM object using JCOM with Native Mode disabled.
    Any help on the compilation error..I tried changing the extends for Dispatch to com.linar.jintegra.Dispatch
    but the other errors are still there.
    To begin with, I think the generated code should not refer to any of the COM data
    types.
    Any help please.
    Thank you in advance,
    Regards,
    Rahul Srivastava
    [email protected]

    Hi,
    I resolved the other errors by changing all references from com.bea.jcom.Variant
    etc to com.linar.jintegra.class name..all were present under the com.linar.jintegra
    package.
    Thank you all anyways,
    Regards,
    rahul
    "Rahul Srivastava" <[email protected]> wrote:
    >
    Hi,
    We are generating java classes for the COM dll using JCOM com2java compiler.
    We are getting a compilation error for import class not found when compiling
    the
    generated Proxy java source code. It can't find the com.bea.jcom.Dispatch
    class that
    the generated Proxy java source code extends. It also can't find com.bea.jcom.Variant
    or com.bea.jcom.Param. These are interfaces or data types or classes used
    by COM
    library.
    I added weblogic.jar to my class path and the only Dispatch class i found
    inside
    the weblogic.jar is com.linar.jintegra.Dispatch;
    We have com objects for which we want to develop an EJB client to interface
    with
    the COM object using JCOM with Native Mode disabled.
    Any help on the compilation error..I tried changing the extends for Dispatch
    to com.linar.jintegra.Dispatch
    but the other errors are still there.
    To begin with, I think the generated code should not refer to any of the
    COM data
    types.
    Any help please.
    Thank you in advance,
    Regards,
    Rahul Srivastava
    [email protected]

Maybe you are looking for