MyException - 我的异常网
输入您需解决的 软件开发问题并开始搜索, 我的异常网可以方便地提供各类 程序错误解决方案。
当前位置: 我的异常网 » J2SE

java tcp发送图片,为什么它总是报错:socket cannot be resolved to a type,该怎么处理

java tcp发送图片,为什么它总是报错:socket cannot be resolved to a type
Java code

public class tcpfasong 
{
    Socket socket;
    BufferedOutputStream os;
    
    tcpfasong() throws SocketException,IOException
    
    {
    try{
   InputStream in=new DataInputStream(new FileInputStream("C:\\Users\\Administrator\\Desktop\\fasong.jpg"));
    
    socket=new Socket(InetAddress.getByName("localhost"),10000);
    os=new BufferedOutputStream(new socket.getOutputStream());
    
    int i;
    byte []buf=new byte[60000];
    while((i=in.read(buf))!=-1)
    {
        os.write(buf);
    }
    }catch(IOException e){System.out.print("1"+e);}
    socket.close();
    }
    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
    new tcpfasong();
    }

}


------解决方案--------------------------------------------------------
引用

socket cannot be resolved to a type

os=new BufferedOutputStream(new socket.getOutputStream());
软件开发 程序错误 异常 Exception Copyright © 2009-2012 MyException 版权所有