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!

char cannot be dereferenced

807597Oct 21 2005 — edited Oct 21 2005
Hello all, I have got a text file from which I want to remove URL tags, i.e.all the text between the characters "<" and ">" and the "<" and ">" tags themselves. The code below gives me the error 'char cannot be dereferenced'. What is causing this error, and does anyone know what is the best way to remove this type of text?

/** This program reads in a text file and removes the URL tags from it
*
*
*@author Myriam
*
*/

import java.io.*;
import cs1ll4.*;
import java.util.*;

public class Best
{
public static void main (String [] args)
{
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(Input.readString("Input Filename:")), "8859_1"));

//open output stream
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(Input.readString("outfilename:")), "8859_1"));

String line = null ;
while( (line = in.readLine() ) != null)
{
int length = (int)line.length();
char [] characterArray = new char[length];
for (int i = 0; i < length; i++)
//if array(0) is "<", do nothing. else print the line.
{
if((characterArray[0].charAt(0)).equals("<"))
{
}
else
{
out.write(line);
}
}

line = in.readLine();
}

out.flush();
out.close();

//close input and output streams
in.close();
}
catch(IOException e)
{
System.out.println("IOException caught");
System.out.println(e.getMessage());
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2005
Added on Oct 21 2005
6 comments
464 views