Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

BufferedReader cannot resolve symbol

843785Aug 31 2008 — edited Sep 1 2008
Hi,

I need some help with a java program which reads xml files to a specified location, running it on a UNIX machine using Java 1.4.1. I modified the code to include the BufferedReader class, but it keeps complaining about not being able to resolve symbol at line 50 & 53. Any help here would be appreciated, since I'm a newbie.

bash-2.05$ javac outputScript.java
outputScript.java:50: cannot resolve symbol
symbol : constructor InputStreamReader (java.lang.String)
location: class java.io.InputStreamReader
BufferedReader in = new BufferedReader(new InputStreamReader("in"));
^
outputScript.java:53: cannot resolve symbol
symbol : method available ()
location: class java.io.BufferedReader
while (in.available() !=0)


Here's the code:

//package cognos8_3;
import java.io.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.File;
/**
* outputScript.java
*
* Copyright Cognos Incorporated. All Rights Reserved.
* Cognos and the Cognos logo are trademarks of Cognos Incorporated.
*
* Description: (KB 1013700) - Sample script that will rename output files generated by CM.OUTPUTLOCATION - Cognos 8.3
*
*/
class outputScript
{
public static void main(String args[])
{
String reportName = "";
String reportViewName = "";
String outputLocation = "/data/cognos/rn_filecp/";
String defName = "";
String ofTime = "";
String burstKey = "";
int countRenamed = 0;

// get the list of desc files in the outputlocation
File descFiles = new File(outputLocation);
String[] children = descFiles.list();
if (children == null || children.length == 0)
{
System.out.println("Invalid file location or no reports found to rename.");
}
else
{
System.out.println("Found " + children.length + " files in this location, search for file names containing '_desc.'.");
for (int i=0; i<children.length; i++)
{
try
{
// Get filename of file or directory
String filename = children;
if (filename.indexOf("_desc.")>=0)
{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream(outputLocation+filename);
FileInputStream bis = new FileInputStream(fstream);
BufferedReader in = new BufferedReader(new InputStreamReader("bis.in"));

// Continue to read lines while there are still some left to read
while (in.available() !=0)
{
String temp = in.readLine();

System.out.println(temp);

// check for report name
if (temp.indexOf("report[@name=")>0)
{
// get beginning of name
int startIndex = temp.indexOf("report[@name=&apos;");
String startString;
int endIndex = 0;
if (startIndex > 0)
{
startString = temp.substring(startIndex);
startIndex = startString.indexOf("&apos;") + 5; //&apos; 6 characters
endIndex = startString.lastIndexOf("&apos;");
}
else
{
startIndex = temp.indexOf("report[@name=");
startString = temp.substring(startIndex);
startIndex = startString.indexOf("@name=") + 6; //&apos; 6 characters
endIndex = startString.lastIndexOf("]");
}

// get report name
reportName = startString.substring(startIndex+1, endIndex);
//System.out.println("Found report name - " + reportName);
}
else if (temp.indexOf("reportView[@name=")>0)
{
// get beginning of name
int startIndex = temp.indexOf("reportView[@name=&apos;");
String startString;
int endIndex = 0;
if (startIndex > 0)
{
startString = temp.substring(startIndex);
startIndex = startString.indexOf("&apos;") + 5; //&apos; 6 characters
endIndex = startString.lastIndexOf("&apos;");
}
else
{
startIndex = temp.indexOf("reportView[@name=");
startString = temp.substring(startIndex);
startIndex = startString.indexOf("@name=") + 6; //&apos; 6 characters
endIndex = startString.lastIndexOf("]");
}

// get report name
reportViewName = startString.substring(startIndex+1, endIndex);
//System.out.println("Found reportView name - " + reportViewName);
}
else if (temp.indexOf("</fileName>")>0) //check for default name
{
defName = temp.substring(temp.indexOf(">")+1, temp.lastIndexOf("<"));
}
else if (temp.indexOf("asOfTime")>=0) // get the time to assure uniqueness when saving
{
ofTime = temp.substring(temp.indexOf(">")+1, temp.lastIndexOf("<"));
// clean colons from time
ofTime = ofTime.replaceAll(":","_");
}
else if (temp.indexOf("</burstKey>")>=0)
{
burstKey = temp.substring(temp.indexOf(">")+1, temp.lastIndexOf("<"));
}
}

in.close();

if (reportName.length() == 0)
{
reportName = reportViewName;
//System.out.println("Renaming using view name - no report name found");
}
String format = defName.substring(defName.length()-3, defName.length());

// new description xml file
File file = new File(outputLocation+filename);
File newDescFile = new File(outputLocation + reportName+"_"+burstKey+"_"+ofTime+"DESC_" + format+ ".xml");

// new renamed specific format file.
File file3 = new File(outputLocation+defName);
File newDefFile = new File(outputLocation + reportName+"_"+burstKey+"_"+ofTime+"."+format);

boolean success = file3.renameTo(newDefFile);
if (!success)
{
// File was not successfully renamed
System.out.println("ERROR attempting to rename - " + file3.getAbsolutePath() + " to \n\t\t" +
newDefFile.getAbsolutePath());
}
else
{
countRenamed++;
// File was successfully renamed
System.out.println(countRenamed +") Renamed - " + file3.getAbsolutePath() + " to \n\t\t" +
newDefFile.getAbsolutePath());
}

// Rename file (or directory)
success = file.renameTo(newDescFile);
if (!success)
{
// File was not successfully renamed
System.out.println("ERROR attempting to rename - " + file.getAbsolutePath() + " to \n\t\t" +
newDescFile.getAbsolutePath());
}
else
{
// File was successfully renamed
System.out.println(" - " + file.getAbsolutePath() + " to \n\t\t" +
newDescFile.getAbsolutePath());

}
}
}
catch (Exception e)
{
System.err.println("File input error " + e.getMessage()) ;
}
}
}
System.out.println("Complete.");
}
}



Thanks,
Nick

Edited by: nickmills on Aug 31, 2008 5:05 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 29 2008
Added on Aug 31 2008
6 comments
2,926 views