IOException in BASE64DecoderStream, help!!!

While I try to parse a mail, I got this error.
Has anyone solve the problem? Please help me! Thanks
I have retreive the raw mail content:
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: (qmail 3237 invoked from network); 7 Dec 2003 09:43:55 -0000
Received: from unknown (HELO mail.MTkzNA.com) (218.19.43.175)
by 0 with SMTP; 7 Dec 2003 09:43:55 -0000
Date: Sun, 07 Dec 03 17:53:30 +0800
From: "info"<[email protected]>
Reply-To: "info"<[email protected]>
To: feedbacktoemail=[email protected]
Subject: LCD
Content-Type: text/plain; charset=gb2312
Content-Transfer-Encoding: base64
ICAgICAgILG+yMvN9c/IyfrH87m6yta7+kxDRNK6vqfP1Mq+xsENCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgIMrWu/qjujEzNTYwNzk4NTcyDQogICAgICAgICAgICAgICAgICAgICAgICAgICAg08q8/qO6
aW5mb0BsY2R6Zy5jb20NCg0KDQoNCg

I am having the same problem. When I am trying to get the content of the message by using getContent() method it returns and instance of com.sun.mail.util.BASE64DecoderStream. Normally this method returns and instance of MultiPart or Part. Does anyone have any ideas what to do?
I would appreciate any suggestions since I really need to solve this issue.
Thanks in advance.

Similar Messages

  • Please help this dummy...How this program works??

    Hi, I am new in Java...I just bought a book and start to learn the java from that book. Here is one of the project exercise and seems that it is difficult for me to understand the flow of the program.
    class HelpClassDemo {
    public static void main(String args [])
    throws java.io.IOException () {
    char choice;
    Help hlpobj = new Help;
    for(;;) {
    do {
    hlpobj.showmenu();
    do {
    choice = (char) System.in.read () ;
    } while (choice == '\n' | choice == '\r');
    } while ( !hlpobj.isvalid (choice) );
    if(choice == 'q' ) break;
    System.out.println("\n");
    hlpobj.helpon(choice);
    Thats what the program code. I don't understand especially after the " } while( !hlpobj.isvalid(choice)); " part. And i don't know what is !hlpobj means....
    Please help.....

    is it indicated the opposite of hlpobj object or the
    opposite of isvalid method?the opposite of the result of isvalid method.
    if isvalid method returns true then the opposite of true which false because of the not sign(!)
    */

  • Replace string in text document help please

    I am trying to make a simple program that changes all "http://" to "https://ssl." in a text document. This is the code I have created so far but the program is not working as intended. I am making this program so I can quicky change the links on my website to the secure webpages.
    import java.io.*;
    public class Main {
        public static void main(String[] args) {
            try {
                File f = new File("textFile.txt");
                RandomAccessFile raf = new RandomAccessFile(f , "rw");
                String line = raf.readLine();
                while(line != null){
                line = line.replaceAll("http://" , "https://ssl.");
                raf.writeChars(line);
                line = raf.readLine();
                raf.close();
            } catch (IOException e) {
    }Any help welcome!

    This is not a Java thing, but a general fact about files and I/O:
    You can't edit a file in place. Do this:
    1. Read the original file a line at a time.
    2. Edit each line and write them out to a new file.
    3. When you are done, close the files. Delete the original file and then rename the new file to the old file's name.

  • How to load a PNG image from a location in CF card

    Hi,
    I am using WTK 2.5.2. I wanted to load a PNG image to Image object. The image is loaded when I have it in the classes folder. But I want to select different image from a different location. If I try to open an Image to createImage(String) from a different location, I get IOException.
    Please help me.
    Thanks
    Deekshit M

    I got the answer, I should be using Image.createImage(InputStream) API. It works fine.
    Thanks
    DM

  • Could somebody tell me how this program works....

    Hi, I am new in Java...I just bought a book and start to learn the java from that book. Here is one of the project exercise and seems that it is difficult for me to understand the flow of the program.
    class HelpClassDemo {
    public static void main(String args [])
    throws java.io.IOException () {
    char choice;
    Help hlpobj = new Help;
    for(;;) {
    do {
    hlpobj.showmenu();
    do {
    choice = (char) System.in.read () ;
    } while (choice == '\n' | choice == '\r');
    } while ( !hlpobj.isvalid (choice) );
    if(choice == 'q' ) break;
    System.out.println("\n");
    hlpobj.helpon(choice);
    Thats what the program code. I don't understand especially after the " } while( !hlpobj.isvalid(choice)); " part. And i don't know what is !hlpobj means....
    Please help.....

    you have already posted in "new to Java " Forum
    Message was edited by:
    srinivass

  • ImageIO image renders slow in scroll pane

    Hello all, I need some help understanding the behavior of BufferedImage(s)
    retrieved from ImageIO.read(). The problem I am having is weird .. I load
    a PNG image via ImageIO.read(), I use it to construct an ImageIcon which
    is later used in a JLabel/JScrollPane for rendering. When I attempt
    to scroll the image in the scroll pane, it is very chunky and slow.
    If I load the same image with ImageIcon(byte[]), there is no problem. The
    image on disk is 186k, when loaded from ImageIcon(), it consumes about
    10M, when loaded with ImageIO about 5M is consumed ... when I scroll,
    the memory usage increase about 9 MB, which can be collected immediatly
    to return to 5M.
    Is ImageIO doing some fancy optimization to preserve memory, if so ... how
    can I alter the settings or turn it off completly. I tried setting
    ImageIO.setUseCache(false); that did nothing as far as I can tell.
    The code to load the image is as follows, I am just using the default right now.
          // perform base64 decoding from buffer
          ByteArrayInputStream bos = new ByteArrayInputStream(decoded);
          try
             image = ImageIO.read(bos);
          catch (IOException ioe)
          }Any help would be greatly appreciated!!!
    Cheers,
    Jody

    I'm not sure if this is exactly what you are looking for but, here's code that works well for me:
    private class MyJLabel extends JLabel {
        public void paintComponent(Graphics g) {
          super.paintComponent(g);
          Graphics2D g2d = (Graphics2D)g;
          URL imageLocation = MyJPanel.class.getResource("myImage.jpg");
          Image myImage = Toolkit.getDefaultToolkit().getImage (imageLocation);
          MediaTracker tracker = new MediaTracker (this);
          tracker.addImage(myImage, 0);
          try { tracker.waitForID(0); } catch (InterruptedException exception) { System.out.println("Image myImage.jpg wasn't loaded!"); }
          g2d.drawImage(myImage, 0, 0, getWidth(), getHeight, this);
    }Once I reload images using the above method, image repainting is very quick. Extend the JLabel (MyJLabel) to overwrite the paint method as above. Should work fast when you do so. You can move the image retrieving code out of the paint method and into the 'MyJLabel' constructor.
    How are you painting the icon and where are you retrieving the image? Can you post more code?
    Regards,
    Devyn

  • Strange Problem..No where the host is associated but still gives UnknownHos

    hallo..
    i have a strange problem...
    I connect to an smtp server to send emails.
    the following is the exception i get always
    it gives me Unknownhostexception : aatsv001 (my PC name)
    but i had never used it to send mails..nor in the email addresses(recipients)..but still it comes..
    the log shows the authentication of smtp and at
    354 go ahead it gives IOException..
    please help..
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth true
    250-PIPELINING
    250 8BITMIME
    DEBUG SMTP Found extension "PIPELINING", arg ""
    DEBUG SMTP Found extension "8BITMIME", arg ""
    DEBUG SMTP: use8bit false
    DEBUG SMTP SENT: MAIL FROM:<[email protected]>
    DEBUG SMTP RCVD: 250 ok
    DEBUG SMTP SENT: RCPT TO:< >
    DEBUG SMTP RCVD: 250 ok
    DEBUG SMTP SENT: RCPT TO:< >
    DEBUG SMTP RCVD: 250 ok
    DEBUG SMTP SENT: RCPT TO:< >
    DEBUG SMTP RCVD: 250 ok
    DEBUG SMTP SENT: RCPT TO:< >
    DEBUG SMTP RCVD: 250 ok
    Verified Addresses
    I removed the email addresses here totally 4
    DEBUG SMTP SENT: DATA
    DEBUG SMTP RCVD: 354 go ahead
    java.net.UnknownHostException: aatsv001
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)
         at java.net.Socket.connect(Socket.java:426)
         at java.net.Socket.connect(Socket.java:376)
         at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
         at sun.net.www.http.HttpClient.openServer(HttpClient.java:386)
         at sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
         at sun.net.www.http.HttpClient.<init>(HttpClient.java:303)
         at sun.net.www.http.HttpClient.<init>(HttpClient.java:264)
         at sun.net.www.http.HttpClient.New(HttpClient.java:336)
         at sun.net.www.http.HttpClient.New(HttpClient.java:317)
         at sun.net.www.http.HttpClient.New(HttpClient.java:312)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:481)
         at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:472)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:574)
         at java.net.URL.openStream(URL.java:960)
         at javax.activation.URLDataSource.getInputStream(URLDataSource.java:100)
         at javax.activation.DataHandler.writeTo(DataHandler.java:297)
         at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
         at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:635)
         at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233)
         at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:68)
         at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:849)
         at javax.activation.DataHandler.writeTo(DataHandler.java:305)
         at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
         at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1527)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:321)
         at com.aat.PudisJobController.PMail.sendEmail(PMail.java:85)
         at com.aat.server.MessageFilterProcessing.doPostProcessing(MessageFilterProcessing.java:186)
         at com.aat.server.MessageFilterProcessing.doPostProcessing(MessageFilterProcessing.java:161)
         at com.aat.PudisJobController.PTask.doPostProcessingForStdReport(PTask.java:247)
         at com.aat.PudisJobController.PTask.saveTaskInfo(PTask.java:222)
         at com.aat.PudisJobController.PTaskWaiter.run(PTaskWaiter.java:45)
    javax.mail.MessagingException: IOException while sending message;
    nested exception is:
         java.net.UnknownHostException: aatsv001
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:353)
         at com.aat.PudisJobController.PMail.sendEmail(PMail.java:85)
         at com.aat.server.MessageFilterProcessing.doPostProcessing(MessageFilterProcessing.java:186)
         at com.aat.server.MessageFilterProcessing.doPostProcessing(MessageFilterProcessing.java:161)
         at com.aat.PudisJobController.PTask.doPostProcessingForStdReport(PTask.java:247)
         at com.aat.PudisJobController.PTask.saveTaskInfo(PTask.java:222)
         at com.aat.PudisJobController.PTaskWaiter.run(PTaskWaiter.java:45)
    can u plss tell me wt actually happening?
    thanx in advance
    K�vi

    re-post

  • HTTP Proxy: My grogram runs even I put a wrong proxy host and port

    I'm new to network programming, so I just use System.setProperty() for easy. But I don't know why this piece of code runs with whatever proxy I set:
    (I download a file and display in a in JTextArea, this is the ActionListener for 'Download' button)
         private class GetFileListener implements ActionListener
              public void actionPerformed(ActionEvent event)
                   if (completeRadioButton.isSelected())
                       try
                            viewFileTextArea.setText("");
                        System.setProperty("http.proxyHost", "http://123.123.123.123");
                        System.setProperty("http.proxyPort", "123");
                        System.setProperty("proxySet", "true");
                           URL url = new URL(completeURLTextField.getText());
                           BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                           String str;
                           while ((str = in.readLine()) != null)
                               viewFileTextArea.append(str + "\n");
                           in.close();
                       catch (MalformedURLException e)
                            viewFileTextArea.setText("URL not found!");
                       catch (IOException e)
         }Please help! Thank you very much!

    This is the new version:
         private class GetFileListener implements ActionListener
              public void actionPerformed(ActionEvent event)
                   if (completeRadioButton.isSelected())
                       try
                            viewFileTextArea.setText("");
                        SocketAddress addr = new InetSocketAddress("123.123.123.123", 123);
                        Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
                        URL url = new URL(completeURLTextField.getText());
                        URLConnection conn = url.openConnection(proxy);
                           BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                           String str;
                           while ((str = in.readLine()) != null)
                               viewFileTextArea.append(str + "\n");
                           in.close();
                       catch (MalformedURLException e)
                            viewFileTextArea.setText("URL not found!");
                       catch (IOException e)
         }but it still runs regardless of what proxy host and port I set in InetSocketAddress. Did I wrongly use Proxy class in the code above?

  • Java.lang.InstantiationException Error

    Hello everyone,
    I am getting the following error when I try to run my applet in the applet viewer.
    java.lang.InstantiationException: Factory
         at java.lang.Class.newInstance0(Class.java:335)
         at java.lang.Class.newInstance(Class.java:303)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:723)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:652)
         at sun.applet.AppletPanel.run(AppletPanel.java:326)
         at java.lang.Thread.run(Thread.java:613)
    Factory is a class which extends JApplet. Here is the init() method:
    public void init(){
         this.setSize(800, 600);
         this.setContentPane(getJContentPane());
         try{
           Factory factory = new Factory("input.txt");
           factory.generateClass();
         catch(IOException e){}
    }Any help would be greatly appreciated.

    Roosh wrote:
    That is correct. Should I have a constructor which contains no arguments in
    order for this to work correctly?Yes. The browser plugin, for example, gets the name of your applet subclass from the HTML:
    <applet code="AppletWorld.class" width="200" height="200">
    </applet> It instantiates your class in a way that requires it to have a constructor that takes no arguments. You didn't define this.
    I also mean that Factory is a class which inherits JApplet, so the Factory is an applet.Am I correct in thinking that Factory's init method creates another instance of Factory? That's the part the doesn't make sense to me.

  • Open  anthor file??

    Hi,
    I do application like notepad but simple ...
    now .... only thing i do open file and the content of the file appear on the textarea
    but the problem i face now is :
    when i open anthor file the content of this file is added to the first file which i opened .
    i want when i open anthor file the content of the first file deleted and the content of the new file appear .
    This is the code which read file and put its content in the textarea :
        private void readFile(File file) {
            int recCount = 0;
            String record = null;
            DataInputStream dis = null;
            try {
                FileInputStream fis = new FileInputStream(file);
                BufferedInputStream bis = new BufferedInputStream(fis);
                dis = new DataInputStream(bis);
                while ((record = dis.readLine()) != null) {
                    recCount++;
                    area.append(record + "\n");
                       } catch (IOException e) {
                JOptionPane.showMessageDialog(null, "you get an IOException error!", "Error", JOptionPane.ERROR_MESSAGE);
            } finally {
                // if the file opened okay, make sure we close it
                if (dis != null) {
                    try {
                        dis.close();
                    } catch (IOException e) {
        }

    >
    i want when i open anthor file the content of the first file deleted and the content of the new file appear .>
        private void readFile(File file) {
            int recCount = 0;
            String record = null;
            DataInputStream dis = null;
            try {
                // clear the TextArea
                area.setText("");
                FileInputStream fis = new FileInputStream(file);
                BufferedInputStream bis = new BufferedInputStream(fis);
                dis = new DataInputStream(bis);
                while ((record = dis.readLine()) != null) {
                    recCount++;
                    area.append(record + "\n");
                       } catch (IOException e) {
                JOptionPane.showMessageDialog(null, "you get an IOException error!", "Error", JOptionPane.ERROR_MESSAGE);
            } finally {
                // if the file opened okay, make sure we close it
                if (dis != null) {
                    try {
                        dis.close();
                    } catch (IOException e) {
        }Please help out the reader by putting one upper case letter at the start of each sentence. This helps people to read the message, and you would not want to make it harder for people to help you, would you?
    And a tip. That word is spelt 'another', not 'anthor'.

  • FileFilter - display in different section

    Hi,
    I am working with a JFileChooser and a FileFilter. The FileFilter allows you to open xml or dtd files. However, I want the files to be displayed in different areas - xml file in one text area and the dtd file in another.
    private void openFile() {
                JFileChooser fc = new JFileChooser(".");
            ExampleFileFilter filter = new ExampleFileFilter("xml");
            filter.setDescription("XML Files");
            fc.addChoosableFileFilter(filter);
            filter = new ExampleFileFilter("dtd");
            filter.setDescription("DTD Files");
            fc.addChoosableFileFilter(filter);
            filter = new ExampleFileFilter("xml");
            filter.addExtension("dtd");
            filter.setDescription("XML and DTD Files");
            fc.addChoosableFileFilter(filter);
                int returnVal = fc.showOpenDialog(this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                     File file = fc.getSelectedFile();
                     try {
                            if(filter.addExtension().equals("xml")){   //???????????
                                  tpr.textArea.read(new FileReader(file), null);
                           else if (filter.addExtension().equals("dtd")){ //?????????
                                  tpr.browserArea.read(new FileReader(file), null);
                        else {
                                  System.out.println("This isn't working");
                     } catch (IOException exp) {}
               } Any help would be great!

    anyone got any ideas?

  • RFID problem

    hi guys i have a problem in my RFID kit program actually i can able to read the
    device while after opening & closing the software originally given by the vendor.
    can anybody help me to do my program as stand aone:
    here my code is :
    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    class opensesay implements  Runnable,SerialPortEventListener {
    static CommPortIdentifier portId;
    static Enumeration portList;
    static SerialPortEvent event;
    InputStream inputStream;
    SerialPort serialPort;
    Thread readThread;
    public static void      main(String[] args) {
    portList = CommPortIdentifier.getPortIdentifiers();
    try
    portId = CommPortIdentifier.getPortIdentifier("COM1");
    opensesay reader = new opensesay();
    catch (NoSuchPortException nspe)
    System.out.println("No port named COM1 found");
    catch (UnsupportedCommOperationException ucoe)
    System.out.println("Could not enable receive threshold.");
    public opensesay() throws UnsupportedCommOperationException {
    try {
    serialPort = (SerialPort) portId.open("opensesayApp", 2000);
    } catch (PortInUseException e) {}
    try {
    serialPort.enableReceiveThreshold(16);
    System.out.println("Port '" + serialPort.getName() + "' settings:");
    System.out.println("\tInput Buffer Size: " + serialPort.getInputBufferSize());
    System.out.println("\tReceive Framing Enabled? " + serialPort.isReceiveFramingEnabled());
    System.out.println("\tReceive Framing Byte: " + serialPort.getReceiveFramingByte());
    System.out.println("\tReceive Threshold Enabled? " + serialPort.isReceiveThresholdEnabled());
    System.out.println("\tReceive Threshold: " + serialPort.getReceiveThreshold());
    System.out.println("\tReceive Timeout Enabled? " + serialPort.isReceiveTimeoutEnabled());
    System.out.println("\tReceive Timeout: " + serialPort.getReceiveTimeout());
    inputStream = serialPort.getInputStream();
    } catch (IOException e) {
    try {
    serialPort.addEventListener(this);
    } catch (TooManyListenersException e) { }
    serialPort.notifyOnDataAvailable(true);
    try {
    serialPort.setSerialPortParams(9600,SerialPort.DATABITS_7,SerialPort.STOPBITS_2,SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {}
    readThread = new Thread(this);
    readThread.start();
    public void run() {
    try {
    Thread.sleep(10000);
    } catch (InterruptedException e) {}
    public void serialEvent(SerialPortEvent event) {
    switch(event.getEventType()) {
    case SerialPortEvent.BI:
    case SerialPortEvent.OE:
    case SerialPortEvent.FE:
    case SerialPortEvent.PE:
    case SerialPortEvent.CD:
    case SerialPortEvent.CTS:
    case SerialPortEvent.DSR:
    case SerialPortEvent.RI:
    case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
    break;
    case SerialPortEvent.DATA_AVAILABLE:
    byte [] readBuffer  = new byte[4096];
    //int [] s = new int [4096];
    try {
    while (inputStream.available() > 0) {
    //System.out.println("Available bytes: " + inputStream.available());
    int numBytes = inputStream.read(readBuffer);
    //for(int i = 0;i<4096;i++) s[i] = readBuffer;
    //System.out.println("Number of bytes read: " + numBytes);
    System.out.println("\"" + new String(readBuffer).trim() + "\"");
    //for(int i = 0;i<4096;i++)System.out.print("\"" + s[i]+ "\"");
    } catch (IOException e) {}
    break;
    help me to trap this problem out.
    thanks in advance

    Hi,
    I have solved my problem...with wsconsole I have generated a rpc/encoded web services. It work fine with C#.Net, EJB and Oracle Sensor Edge Server...
    WOW !!!
    Bye Bye
    Mauro

  • Send emails with attachments residing in the network

    Hi All,
    My requirement is to send email with attachments. I am using javamail and it works fine only if the attachment resides in the local machine.
    If the attachment resides in the network [the folder is shared by the user], the application gives me IOException.
    Please help. Let me know if I am not clear.

    Please find the trace below . Also I am able to browse the share but haven't tried writing a test app.
    javax.mail.MessagingException: IOException while sending message
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:595)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at SendEmail.sendMail(SendEmail.java:66)
    at FetchDetails.fetchResultSet(FetchDetails.java:69)
    at FetchDetails.<init>(FetchDetails.java:36)
    at Index.main(Index.java:3)
    Caused by: java.io.FileNotFoundException: \xxx.xxx.xx.xxx\dinesh\dialog.gif (The
    system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:103)
    at javax.activation.FileDataSource.getInputStream(FileDataSource.java:80
    at javax.activation.DataHandler.writeTo(DataHandler.java:287)
    at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1248)
    at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:747)
    at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:361)
    at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:85
    at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:83
    9)
    at javax.activation.DataHandler.writeTo(DataHandler.java:295)
    at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1248)
    at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1673)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:555)
    ... 6 more
    Cant send mail. IOException while sending message

  • End of stream problem

    hi all
    im having some problems with finding the end of an input stream. Basically im trying to read from a stream and then write the stream to the text box. But i can figure when the end of the stream is. The read method im using returns an int not a byte, otherwise id use:
    if(input == -1) return;
    but because of it being an int it never returns -1 like a byte would so im having trouble. Here's the code.
    try
          int i = socketInput.read();
          while(true)
            if (i == -1) return;
            out.write(i);       
             i = socketInput.read();
        catch(IOException ioe){}any help? thanks.
    btw, i know the coding probably sucks, im still trying to get my head round it.

    From the InputStream java doc concerning method read():
    read
    public abstract int read()
                      throws IOException
        Reads the next byte of data from the input stream. The value byte is returned as an int
        in the range 0 to 255. If no byte is available because the end of the stream has been
        reached, the value -1 is returned. This method blocks until input data is available, the
        end of the stream is detected, or an exception is thrown.Int is find for the return of -1, but if you are really using a socket, that will probably not return -1 until the socket is closed. In fact, it will block if nothing is available. Try using available() to see if anything is there to read before doing the read(). I don't know if you can assume that, if the number of bytes available is zero, that you are done.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can i access Motorola phone memory?

    Hi to all,
    I have a big problem.
    I don't get at to access to motorola phone memory to read audio files.
    In particular i want to list all files inside all file system mounted on motorola phone.
    I tried in this manner:
    ArrayList array = new ArrayList();
    try {
    Enumeration enumFileSystem = FileSystemRegistry.listRoots();
    while (enumFileSystem.hasMoreElements()) {
    String root = (String) enumFileSystem.nextElement();
    FileConnection fc = (FileConnection)Connector.open("file:///" + root, Connector.READ);
    Enumeration enumFiles = fc.list();
         while (enumFiles.hasMoreElements()) {
    array.add((String)enumFiles.nextElement());
    }catch (IOException e) {}
    Please help me!
    It's very urgent!
    Thanks for any suggestions.

    Hi parvathy,
    Thanx for ur reply.
    I m sorry to say that it is not working in the device i870. While running the aplication, I got an error message "File System not supported" . When I call FileSystemRegistry.listRoots(), ./, / and /Storage Card were displayed in the list. When I tried to access ./ root, "bad file name" error is displayed. For the other two roots, I got "File System not supported" error. I was able to access and load the contents of the Starage Card by using the file URL "file:///Storage Card/". I want to read the pictures in the phone memory of iDEN phones.
    Please help Me...

Maybe you are looking for