placeservice.java

来自「这是一款基于PlaceLab软件开发的导航系统中间件的客户端程序.」· Java 代码 · 共 61 行

JAVA
61
字号
/* * Created on Oct 4, 2004 * */package org.placelab.midp.server;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.PrintStream;import org.placelab.core.PlacelabProperties;public class PlaceService implements BluetoothService {	public String getName() {		return "Place Downloader";	}	public byte getServiceType() {		return BluetoothService.PLACE_UPLOAD_SERVICE;	}	public void newClient(DataInputStream in, DataOutputStream out) {		File f = null;				for (int i = 0;; i++) {			f = new File(PlacelabProperties.get("placelab.datadir") + File.separator + 					"places-" + i + ".txt");						if (!f.exists())				break;		}				try {			System.out.println("Saving to " + f.getName());			PrintStream ps = new PrintStream(new FileOutputStream(f));			String name = in.readUTF();			String number = in.readUTF();			ps.println(name + "|" + number);						int count = in.readInt();			while (count-- > 0) {				ps.println(in.readUTF());			}						ps.close();		} catch (IOException e) {			System.err.println("Failed: " + e);			e.printStackTrace();		}			}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?