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


Java DataInputStream.readUTF方法代码示例

本文整理汇总了Java中java.io.DataInputStream.readUTF方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputStream.readUTF方法的具体用法?Java DataInputStream.readUTF怎么用?Java DataInputStream.readUTF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.DataInputStream的用法示例。


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

示例1: readUTF

import java.io.DataInputStream; //导入方法依赖的package包/类
public String readUTF() throws IOException {
    this.bitOffset = 0;

    // Fix 4494369: method ImageInputStreamImpl.readUTF()
    // does not work as specified (it should always assume
    // network byte order).
    ByteOrder oldByteOrder = getByteOrder();
    setByteOrder(ByteOrder.BIG_ENDIAN);

    String ret;
    try {
        ret = DataInputStream.readUTF(this);
    } catch (IOException e) {
        // Restore the old byte order even if an exception occurs
        setByteOrder(oldByteOrder);
        throw e;
    }

    setByteOrder(oldByteOrder);
    return ret;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:ImageInputStreamImpl.java

示例2: read

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Read partition meta from input stream
 * @param input
 * @throws IOException
 */
public void read(DataInputStream input) throws IOException {
  partId = input.readInt();
  startRow = input.readInt();
  endRow = input.readInt();
  startCol = input.readLong();
  endCol = input.readLong();
  nnz = input.readLong();
  fileName = input.readUTF();
  offset = input.readLong();
  length = input.readLong();
  rowMetas = new HashMap<>();

  int rowIndexNum = input.readInt();
  for(int i = 0; i < rowIndexNum; i++) {
    RowOffset rowOffset = new RowOffset(input.readInt(), input.readLong());
    rowMetas.put(rowOffset.rowId, rowOffset);
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:24,代码来源:ModelPartitionMeta.java

示例3: load

import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
public FileSystem load(FileSystem previous, ByteBuffer bb) throws IOException {
    byte[] arr = new byte[bb.limit()];
    bb.get(arr);
    DataInputStream is = new DataInputStream(new ByteArrayInputStream(arr));
    List<URL> urls = new ArrayList<URL>();
    while (is.available() > 0) {
        String u = is.readUTF();
        urls.add(new URL(u));
    }
    try {
        XMLFileSystem fs = (XMLFileSystem)previous;
        fs.setXmlUrls(urls.toArray(new URL[urls.size()]));
        return fs;
    } catch (PropertyVetoException pve) {
        throw (IOException) new IOException(pve.toString()).initCause(pve);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:LayerCacheManager.java

示例4: readRelativePath

import java.io.DataInputStream; //导入方法依赖的package包/类
/** Reads relative path from stream.
 */
public static String readRelativePath(DataInputStream dis) throws IOException {
    String index = dis.readUTF();
    if (index.isEmpty()) {
        return index;
    }
    String relative = dis.readUTF();
    if ("user".equals(index)) { // NOI18N
        return System.getProperty("netbeans.user").concat(relative); // NOI18N
    }
    if ("home".equals(index)) { // NOI18N
        return System.getProperty("netbeans.home").concat(relative); // NOI18N
    }
    if ("abs".equals(index)) { // NOI18N
        return relative;
    }
    int indx = 0;
    try {
        indx = Integer.parseInt(index);
    } catch (NumberFormatException nfe) {
        throw new IOException(nfe);
    }
    return dirs()[indx].concat(relative); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:RelPaths.java

示例5: read

import java.io.DataInputStream; //导入方法依赖的package包/类
public static CompiledScene read(final Camera camera, final DataInputStream dataInputStream) {
	try {
		final String name = dataInputStream.readUTF();
		
		final float[] boundingVolumeHierarchy = doReadFloatArray(dataInputStream);
		final float[] cameraArray = doReadFloatArray(dataInputStream, camera.getArray());
		final float[] point2s = doReadFloatArray(dataInputStream);
		final float[] point3s = doReadFloatArray(dataInputStream);
		final float[] shapes = doReadFloatArray(dataInputStream);
		final float[] surfaces = doReadFloatArray(dataInputStream);
		final float[] textures = doReadFloatArray(dataInputStream);
		final float[] vector3s = doReadFloatArray(dataInputStream);
		final int[] shapeOffsets = doReadIntArray(dataInputStream);
		
		return new CompiledScene(boundingVolumeHierarchy, cameraArray, point2s, point3s, shapes, surfaces, textures, vector3s, shapeOffsets, name);
	} catch(final IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
开发者ID:macroing,项目名称:Dayflower-Path-Tracer,代码行数:20,代码来源:CompiledScene.java

示例6: createFromStream

import java.io.DataInputStream; //导入方法依赖的package包/类
private static CanonicalCookie createFromStream(DataInputStream in) throws IOException {
    // URL is no longer included. Keep for backward compatability.
    in.readUTF();
    return new CanonicalCookie(in.readUTF(), in.readUTF(), in.readUTF(), in.readUTF(),
            in.readLong(), in.readLong(), in.readLong(), in.readBoolean(), in.readBoolean(),
            in.readInt(), in.readInt());
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:CanonicalCookie.java

示例7: readUTF

import java.io.DataInputStream; //导入方法依赖的package包/类
public String readUTF() throws IOException {
int len = readUnsignedShort();
byte[] bytes = new byte[len+2];
bytes[0] = (byte)((len >> 8) & 0xFF);
bytes[1] = (byte)(len & 0xFF);
readFully(bytes, 2, len);
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes));
return dis.readUTF();
   }
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:10,代码来源:RandomAccessFileReader.java

示例8: loadPlayerData

import java.io.DataInputStream; //导入方法依赖的package包/类
private Player loadPlayerData(String playerName, String saveName) {
	Player newPlayer = null;
	try {
		// open file
		File file = new File(savePath + saveName + "/player/" + playerName + ".data");
		DataInputStream in = new DataInputStream(new FileInputStream(file));

		byte version = (byte) in.read();
		if (version != SAVE_VERSION_PLAYER) {
			Logger.error("Version of player file is not correct!");
			game.createEvent(new MessageEvent(Event.Type.FAILED_LOAD,
					"Incompatible version '" + version + "'. Can't load file (player)."));
		}

		// load data
		String name = in.readUTF();
		if (!name.equals(playerName)) {
			Logger.error("Playerfile is corrupted: name");
			game.createEvent(new MessageEvent(Event.Type.FAILED_LOAD, "Playerdata of save is corrupted: name"));
		}
		newPlayer = new Player(name);

		newPlayer.position.x = in.readFloat();
		newPlayer.position.y = in.readFloat();
		newPlayer.position.z = in.readFloat();

		in.close();
	} catch (IOException e1) {
		Logger.warn("Player data could not be loaded!");
	}
	return newPlayer;
}
 
开发者ID:erikgoe,项目名称:Cubeland,代码行数:33,代码来源:SavingSystem.java

示例9: readStringArray

import java.io.DataInputStream; //导入方法依赖的package包/类
private static String[] readStringArray(DataInputStream dis, int count) throws IOException {
    String[] ret = new String[count];
    for (int i = 0; i < count; i++) {
        ret[i] = dis.readUTF();
    }

    return ret;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:Currency.java

示例10: readNullableString

import java.io.DataInputStream; //导入方法依赖的package包/类
public static String readNullableString(DataInputStream in) throws IOException {
    if (in.read() != 0) {
        return in.readUTF();
    } else {
        return null;
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:8,代码来源:DurableUtils.java

示例11: parse

import java.io.DataInputStream; //导入方法依赖的package包/类
public static FileExploreRequestAction parse(DataInputStream dis) throws IOException
{
	String directory = dis.readUTF();
	String file = dis.readUTF();
	
	return new FileExploreRequestAction(directory, file);
}
 
开发者ID:Elbehiry,项目名称:Pc-Control,代码行数:8,代码来源:FileExploreRequestAction.java

示例12: readString

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Reads a NULL-TERMINATED String.
 *
 * @throws IOException if attempt to read past end of packet.
 */
String readString() throws IOException {
    /* Would be MUCH easier to do this with Java6's String
     * encoding/decoding operations */
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write((byte) 'X');
    baos.write((byte) 'X');
    // Place-holders to be replaced with short length

    int i;
    while ((i = readByte()) > 0) {
        baos.write((byte) i);
    }
    byte[] ba = baos.toByteArray();
    baos.close();

    int len = ba.length - 2;
    ba[0] = (byte) (len >>> 8);
    ba[1] = (byte) len;

    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(ba));
    String s = dis.readUTF();
    //String s = DataInputStream.readUTF(dis);
    // TODO:  Test the previous two to see if one works better for
    // high-order characters.
    dis.close();
    return s;
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:33,代码来源:OdbcPacketInputStream.java

示例13: BinaryConstantPool

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Constructor
 */
BinaryConstantPool(DataInputStream in) throws IOException {
    // JVM 4.1 ClassFile.constant_pool_count
    types = new byte[in.readUnsignedShort()];
    cpool = new Object[types.length];
    for (int i = 1 ; i < cpool.length ; i++) {
        int j = i;
        // JVM 4.4 cp_info.tag
        switch(types[i] = in.readByte()) {
          case CONSTANT_UTF8:
            cpool[i] = in.readUTF();
            break;

          case CONSTANT_INTEGER:
            cpool[i] = new Integer(in.readInt());
            break;
          case CONSTANT_FLOAT:
            cpool[i] = new Float(in.readFloat());
            break;
          case CONSTANT_LONG:
            cpool[i++] = new Long(in.readLong());
            break;
          case CONSTANT_DOUBLE:
            cpool[i++] = new Double(in.readDouble());
            break;

          case CONSTANT_CLASS:
          case CONSTANT_STRING:
            // JVM 4.4.3 CONSTANT_String_info.string_index
            // or JVM 4.4.1 CONSTANT_Class_info.name_index
            cpool[i] = new Integer(in.readUnsignedShort());
            break;

          case CONSTANT_FIELD:
          case CONSTANT_METHOD:
          case CONSTANT_INTERFACEMETHOD:
          case CONSTANT_NAMEANDTYPE:
            // JVM 4.4.2 CONSTANT_*ref_info.class_index & name_and_type_index
            cpool[i] = new Integer((in.readUnsignedShort() << 16) | in.readUnsignedShort());
            break;

          case CONSTANT_METHODHANDLE:
            cpool[i] = readBytes(in, 3);
            break;
          case CONSTANT_METHODTYPE:
            cpool[i] = readBytes(in, 2);
            break;
          case CONSTANT_INVOKEDYNAMIC:
            cpool[i] = readBytes(in, 4);
            break;

          case 0:
          default:
            throw new ClassFormatError("invalid constant type: " + (int)types[i]);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:BinaryConstantPool.java

示例14: readText

import java.io.DataInputStream; //导入方法依赖的package包/类
public String readText() throws IOException {
    DataInputStream input = new DataInputStream(this.sslSocket.getInputStream());
    String text = input.readUTF();
    return text;
}
 
开发者ID:luisbraganca,项目名称:file-transfer,代码行数:6,代码来源:Transmission.java

示例15: engineLoad

import java.io.DataInputStream; //导入方法依赖的package包/类
public void engineLoad(InputStream in, char[] passwd)
    throws IOException, NoSuchAlgorithmException, CertificateException
{
    MessageDigest md = MessageDigest.getInstance("SHA");
    if (passwd != null) md.update(charsToBytes(passwd));
    md.update("Mighty Aphrodite".getBytes("UTF-8")); // HAR HAR
    aliases.clear();
    trustedCerts.clear();
    privateKeys.clear();
    certChains.clear();
    dates.clear();
    if (in == null) return;
    DataInputStream din = new DataInputStream(new DigestInputStream(in, md));
    if (din.readInt() != MAGIC)
        throw new IOException("not a JavaKeyStore");
    din.readInt();  // version no.
    final int n = din.readInt();
    aliases.ensureCapacity(n);
    if (n < 0)
        throw new LoadKeystoreException("Malformed key store");
    for (int i = 0; i < n; i++)
    {
        int type = din.readInt();
        String alias = din.readUTF();
        aliases.add(alias);
        dates.put(alias, new Date(din.readLong()));
        switch (type)
        {
            case PRIVATE_KEY:
                int len = din.readInt();
                byte[] encoded = new byte[len];
                din.read(encoded);
                privateKeys.put(alias, encoded);
                int count = din.readInt();
                Certificate[] chain = new Certificate[count];
                for (int j = 0; j < count; j++)
                    chain[j] = readCert(din);
                certChains.put(alias, chain);
                break;

            case TRUSTED_CERT:
                trustedCerts.put(alias, readCert(din));
                break;

            default:
                throw new LoadKeystoreException("Malformed key store");
        }
    }

    if (passwd != null) {
        byte[] computedHash = md.digest();
        byte[] storedHash = new byte[20];
        din.read(storedHash);
        if (!MessageDigest.isEqual(storedHash, computedHash)) {
            throw new LoadKeystoreException("Incorrect password, or integrity check failed.");
        }
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:59,代码来源:JKS.java


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