当前位置: 首页>>代码示例>>Java>>正文


Java Messages类代码示例

本文整理汇总了Java中org.apache.harmony.luni.internal.nls.Messages的典型用法代码示例。如果您正苦于以下问题:Java Messages类的具体用法?Java Messages怎么用?Java Messages使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Messages类属于org.apache.harmony.luni.internal.nls包,在下文中一共展示了Messages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cd

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Change the server directory to that specified in the URL
 */
private void cd() throws IOException {
    int idx = url.getFile().lastIndexOf('/');

    if (idx > 0) {
        String dir = url.getFile().substring(0, idx);
        write("CWD " + dir + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
        int reply = getReply();
        if (reply != FTP_FILEOK && dir.length() > 0 && dir.charAt(0) == '/') {
            write("CWD " + dir.substring(1) + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
            reply = getReply();
        }
        if (reply != FTP_FILEOK) {
            throw new IOException(Messages.getString("luni.1C")); //$NON-NLS-1$
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:FtpURLConnection.java

示例2: read

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Reads at most {@code count} characters from this CharArrayReader and
 * stores them at {@code offset} in the character array {@code buf}.
 * Returns the number of characters actually read or -1 if the end of reader
 * was encountered.
 * 
 * @param buffer
 *            the character array to store the characters read.
 * @param offset
 *            the initial position in {@code buffer} to store the characters
 *            read from this reader.
 * @param len
 *            the maximum number of characters to read.
 * @return number of characters read or -1 if the end of the reader has been
 *         reached.
 * @throws IndexOutOfBoundsException
 *             if {@code offset < 0} or {@code len < 0}, or if
 *             {@code offset + len} is bigger than the size of
 *             {@code buffer}.
 * @throws IOException
 *             if this reader is closed.
 */
@Override
public int read(char buffer[], int offset, int len) throws IOException {
    if (offset < 0 || offset > buffer.length) {
        // luni.12=Offset out of bounds \: {0}
        throw new ArrayIndexOutOfBoundsException(
                Messages.getString("luni.12", offset)); //$NON-NLS-1$
    }
    if (len < 0 || len > buffer.length - offset) {
        // luni.18=Length out of bounds \: {0}
        throw new ArrayIndexOutOfBoundsException(
                Messages.getString("luni.18", len)); //$NON-NLS-1$
    }
    synchronized (lock) {
        if (isClosed()) {
            throw new IOException(Messages.getString("luni.A9")); //$NON-NLS-1$
        }
        if (pos < this.count) {
            int bytesRead = pos + len > this.count ? this.count - pos : len;
            System.arraycopy(this.buf, pos, buffer, offset, bytesRead);
            pos += bytesRead;
            return bytesRead;
        }
        return -1;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:48,代码来源:CharArrayReader.java

示例3: getInputStream

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Creates an input stream for reading from this URL Connection.
 * 
 * @return the input stream
 * 
 * @throws IOException
 *             if an IO error occurs while connecting to the resource.
 */
@Override
public InputStream getInputStream() throws IOException {
    if (closed) {
        // luni.33=Inputstream of the JarURLConnection has been closed
        throw new IllegalStateException(Messages.getString("luni.33")); //$NON-NLS-1$
    }
    connect();
    if (jarInput != null) {
        return jarInput;
    }
    if (jarEntry == null) {
        // luni.34=Jar entry not specified
        throw new IOException(Messages.getString("luni.34")); //$NON-NLS-1$
    }
    return jarInput = new JarURLConnectionInputStream(jarFile
            .getInputStream(jarEntry), jarFile);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:JarURLConnectionImpl.java

示例4: FileInputStream

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Constructs a new {@code FileInputStream} based on {@code file}.
 * 
 * @param file
 *            the file from which this stream reads.
 * @throws FileNotFoundException
 *             if {@code file} does not exist.
 * @throws SecurityException
 *             if a {@code SecurityManager} is installed and it denies the
 *             read request.
 */
public FileInputStream(File file) throws FileNotFoundException {
    super();
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        // For compatibility, nulls are passed to the manager.
        String filePath = (null == file ? null : file.getPath());
        security.checkRead(filePath);
    }
    if (file == null) {
        // luni.4D=Argument must not be null
        throw new NullPointerException(Messages.getString("luni.4D")); //$NON-NLS-1$
    }
    fd = new FileDescriptor();
    fd.readOnly = true;
    fd.descriptor = fileSystem.open(file.properPath(true),
            IFileSystem.O_RDONLY);
    innerFD = true;
    channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
            IFileSystem.O_RDONLY);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:FileInputStream.java

示例5: Scanner

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Creates a {@code Scanner} with the specified {@code File} as input. The specified charset
 * is applied when reading the file.
 * 
 * @param src
 *            the file to be scanned.
 * @param charsetName
 *            the name of the encoding type of the file.
 * @throws FileNotFoundException
 *             if the specified file does not exist.
 * @throws IllegalArgumentException
 *             if the specified coding does not exist.
 */
public Scanner(File src, String charsetName) throws FileNotFoundException {
    if (null == src) {
        throw new NullPointerException(Messages
                .getString("luni.DB")); //$NON-NLS-1$
    }
    FileInputStream fis = new FileInputStream(src);
    if (null == charsetName) {
        throw new IllegalArgumentException(Messages
                .getString("luni.DC")); //$NON-NLS-1$
    }
    try {
        input = new InputStreamReader(fis, charsetName);
    } catch (UnsupportedEncodingException e) {
        try {
            fis.close();
        } catch (IOException ioException) {
            // ignore
        }
        throw new IllegalArgumentException(e.getMessage());
    }
    initialization();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:36,代码来源:Scanner.java

示例6: openConnection

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * The behaviour of this method is the same as openConnection(URL).
 * <code>proxy</code> is not used in FileURLConnection.
 * 
 * @param url
 *            the URL which the connection is pointing to
 * @param proxy
 *            Proxy
 * @return a connection to the resource pointed by this url.
 * 
 * @throws IOException
 *             if this handler fails to establish a connection.
 * @throws IllegalArgumentException
 *             if the url argument is null.
 * @throws UnsupportedOperationException
 *             if the protocol handler doesn't support this method.
 */
@Override
public URLConnection openConnection(URL url, Proxy proxy)
        throws IOException {
    if (null == url) {
        // luni.1B=url and proxy can not be null
        throw new IllegalArgumentException(Messages.getString("luni.1B")); //$NON-NLS-1$
    }

    String host = url.getHost();
    if (host == null || host.length() == 0
            || host.equalsIgnoreCase("localhost")) { //$NON-NLS-1$
        return new FileURLConnection(url);
    }

    // If a hostname is specified try to get the resource using FTP
    URL ftpURL = new URL("ftp", host, url.getFile()); //$NON-NLS-1$
    return (proxy == null) ? ftpURL.openConnection() : ftpURL
            .openConnection(proxy);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:37,代码来源:Handler.java

示例7: write

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
@Override
public synchronized void write(int data) throws IOException {
    if (closed) {
        throw new IOException(Messages.getString("luni.24")); //$NON-NLS-1$
    }
    if (limit >= 0) {
        if (limit == 0) {
            throw new IOException(Messages.getString("luni.26")); //$NON-NLS-1$
        }
        limit--;
    }
    cache.write(data);
    if (writeToSocket && cache.size() >= cacheLength) {
        sendCache(false);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:HttpURLConnectionImpl.java

示例8: readClassDesc

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Reads a class descriptor (an {@code ObjectStreamClass}) from the
 * stream.
 * 
 * @return the class descriptor read from the stream
 * 
 * @throws IOException
 *             If an IO exception happened when reading the class
 *             descriptor.
 * @throws ClassNotFoundException
 *             If the class corresponding to the class descriptor could not
 *             be found.
 */
private ObjectStreamClass readClassDesc() throws ClassNotFoundException,
        IOException {
    byte tc = nextTC();
    switch (tc) {
        case TC_CLASSDESC:
            return readNewClassDesc(false);
        case TC_PROXYCLASSDESC:
            Class<?> proxyClass = readNewProxyClassDesc();
            ObjectStreamClass streamClass = ObjectStreamClass
                    .lookup(proxyClass);
            streamClass.setLoadFields(new ObjectStreamField[0]);
            registerObjectRead(streamClass, nextHandle(), false);
            checkedSetSuperClassDesc(streamClass, readClassDesc());
            return streamClass;
        case TC_REFERENCE:
            return (ObjectStreamClass) readCyclicReference();
        case TC_NULL:
            return null;
        default:
            throw new StreamCorruptedException(Messages.getString(
                    "luni.BC", Integer.toHexString(tc & 0xff))); //$NON-NLS-1$
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:37,代码来源:ObjectInputStream.java

示例9: login

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
private void login() throws IOException {
    int reply;
    reply = getReply();
    if (reply == FTP_USERREADY) {
    } else {
        throw new IOException(Messages.getString("luni.1D", url.getHost())); //$NON-NLS-1$
    }
    write("USER " + username + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
    reply = getReply();
    if (reply == FTP_PASWD || reply == FTP_LOGGEDIN) {
    } else {
        throw new IOException(Messages.getString("luni.20", url.getHost())); //$NON-NLS-1$
    }
    if (reply == FTP_PASWD) {
        write("PASS " + password + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
        reply = getReply();
        if (!(reply == FTP_OK || reply == FTP_USERREADY || reply == FTP_LOGGEDIN)) {
            throw new IOException(Messages.getString("luni.20", url.getHost())); //$NON-NLS-1$
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:FtpURLConnection.java

示例10: createNewFile

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Creates a new, empty file on the file system according to the path
 * information stored in this file.
 * 
 * @return {@code true} if the file has been created, {@code false} if it
 *         already exists.
 * @throws IOException
 *             if an I/O error occurs or the directory does not exist where
 *             the file should have been created.
 * @throws SecurityException
 *             if a {@code SecurityManager} is installed and it denies write
 *             access for this file.
 */
public boolean createNewFile() throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkWrite(path);
    }
    if (0 == path.length()) {
        throw new IOException(Messages.getString("luni.B3")); //$NON-NLS-1$
    }
    int result = newFileImpl(properPath(true));
    switch (result) {
        case 0:
            return true;
        case 1:
            return false;
        default:
            throw new IOException(Messages.getString("luni.B4", path)); //$NON-NLS-1$
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:File.java

示例11: setProxy

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
private void setProxy(String proxy) {
    int index = proxy.indexOf(':');
    if (index == -1) {
        proxyName = proxy;
        hostPort = defaultPort;
    } else {
        proxyName = proxy.substring(0, index);
        String port = proxy.substring(index + 1);
        try {
            hostPort = Integer.parseInt(port);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(Messages.getString("luni.30", port)); //$NON-NLS-1$
        }
        if (hostPort < 0 || hostPort > 65535) {
            throw new IllegalArgumentException(Messages.getString("luni.31")); //$NON-NLS-1$
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:HttpURLConnectionImpl.java

示例12: bind

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Binds this socket to the local address and port specified by {@code
 * localAddr}. If this value is {@code null} any free port on a valid local
 * address is used.
 * 
 * @param localAddr
 *            the local machine address and port to bind on.
 * @throws IllegalArgumentException
 *             if the SocketAddress is not supported
 * @throws SocketException
 *             if the socket is already bound or a problem occurs during
 *             binding.
 */
public void bind(SocketAddress localAddr) throws SocketException {
    checkClosedAndBind(false);
    int localPort = 0;
    InetAddress addr = InetAddress.ANY;
    if (localAddr != null) {
        if (!(localAddr instanceof InetSocketAddress)) {
            throw new IllegalArgumentException(Messages.getString(
                    "luni.49", localAddr.getClass())); //$NON-NLS-1$
        }
        InetSocketAddress inetAddr = (InetSocketAddress) localAddr;
        addr = inetAddr.getAddress();
        if (addr == null) {
            throw new SocketException(Messages.getString(
                    "luni.1A", inetAddr.getHostName())); //$NON-NLS-1$
        }
        localPort = inetAddr.getPort();
        checkListen(localPort);
    }
    impl.bind(localPort, addr);
    isBound = true;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:DatagramSocket.java

示例13: connect

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
/**
 * Connects this stream to a {@link PipedInputStream}. Any data written to
 * this output stream becomes readable in the input stream.
 * 
 * @param stream
 *            the destination input stream.
 * @throws IOException
 *             if either stream is already connected.
 */
public void connect(PipedInputStream stream) throws IOException {
    if (null == stream) {
        throw new NullPointerException();
    }
    if (this.dest != null) {
        throw new IOException(Messages.getString("luni.5F")); //$NON-NLS-1$
    }
    synchronized (stream) {
        if (stream.isConnected) {
            throw new IOException(Messages.getString("luni.D0")); //$NON-NLS-1$
        }
        if (stream.buffer == null) {
            stream.buffer = new byte[PipedInputStream.PIPE_SIZE];
        }
        stream.isConnected = true;
        this.dest = stream;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:PipedOutputStream.java

示例14: makeNewHandler

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
private synchronized void makeNewHandler() {
    while (!searchList.isEmpty()) {
        URL nextCandidate = searchList.remove(0);
        if (nextCandidate == null) {  // luni.94=One of urls is null
            throw new NullPointerException(Messages.getString("luni.94")); //$NON-NLS-1$
        }
        if (!handlerMap.containsKey(nextCandidate)) {
            URLHandler result;
            String protocol = nextCandidate.getProtocol();
            if (protocol.equals("jar")) { //$NON-NLS-1$
                result = createURLJarHandler(nextCandidate);
            } else if (protocol.equals("file")) { //$NON-NLS-1$
                result = createURLFileHandler(nextCandidate);
            } else {
                result = createURLHandler(nextCandidate);
            }
            if (result != null) {
                handlerMap.put(nextCandidate, result);
                handlerList.add(result);
                return;
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:URLClassLoader.java

示例15: read

import org.apache.harmony.luni.internal.nls.Messages; //导入依赖的package包/类
@Override
public int read(byte[] buffer, int offset, int nbytes) throws IOException {
    synchronized (this) {
        if (handle == -1) {
            return -1;
        }
        if (nbytes > buffer.length  || nbytes < 0) {
            // luni.18=Length out of bounds \: {0}
            throw new ArrayIndexOutOfBoundsException(Messages.getString("luni.18", nbytes)); //$NON-NLS-1$
        }
        if (offset < 0 || offset > buffer.length - nbytes) {
            // luni.12=Offset out of bounds \: {0}
            throw new ArrayIndexOutOfBoundsException(Messages.getString("luni.12", offset)); //$NON-NLS-1$
        }
        return readImpl(buffer, offset, nbytes, handle);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:ProcessInputStream.java


注:本文中的org.apache.harmony.luni.internal.nls.Messages类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。