ファイルのテキストデータを読み込む

[参考記事] テキストデータをファイルに書き込む BufferedWriterの使用例

サンプルコード

	public String readFile(InputStream is){
		byte[] buff = new byte[512];
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		int tag = -1;
		try {
			while((tag=is.read(buff))!=-1){
				os.write(buff,0,tag);
			}
			String tem = new String(os.toByteArray());
			
			return tem;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

関連記事

スポンサーリンク

FAT(File Allocation Table)ファイルシステムの仕様 FAT16 FAT32 exFAT VFAT

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る