📄 mutablestrings.java
字号:
package it.unimi.dsi.mg4j.util;/* * MG4J: Managing Gigabytes for Java * * Copyright (C) 2005-2007 Sebastiano Vigna * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITfNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */import it.unimi.dsi.fastutil.io.FastBufferedInputStream;import it.unimi.dsi.fastutil.io.FastBufferedOutputStream;import it.unimi.dsi.fastutil.objects.ObjectArrays;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;/** A static container providing utility objects and method for {@link it.unimi.dsi.mg4j.util.MutableString}s. * @deprecated Moved to <code>dsiutils</code>. */@Deprecatedpublic class MutableStrings { public static final MutableString[] EMPTY_ARRAY = {}; private MutableStrings() {} /** Stores a fragment of an array of mutable strings writing to an output stream in self-delimiting UTF-8 format. * @param array an array of mutable strings. * @param offset the first string to be stored. * @param length the number of strings to be stored. * @param os an output stream. */ public static void storeMutableStringsSelfDelimUTF8( final MutableString[] array, final int offset, final int length, final OutputStream os ) throws IOException { ObjectArrays.ensureOffsetLength( array, offset, length ); for( int i = 0; i < length; i++ ) array[ i + offset ].writeSelfDelimUTF8( os ); } /** Stores an array of mutable strings writing to an output stream in self-delimiting UTF-8 format. * @param array an array of mutable strings. * @param os an output stream. */ public static void storeMutableStringsSelfDelimUTF8( final MutableString[] array, final OutputStream os ) throws IOException { storeMutableStringsSelfDelimUTF8( array, 0, array.length, os ); } /** Stores a fragment of an array of mutable strings writing to a file in self-delimiting UTF-8 format. * @param array an array of mutable strings. * @param offset the first string to be stored. * @param length the number of strings to be stored. * @param filename a filename. */ public static void storeMutableStringsSelfDelimUTF8( final MutableString[] array, final int offset, final int length, final CharSequence filename ) throws IOException { FastBufferedOutputStream fbos = new FastBufferedOutputStream( new FileOutputStream( filename.toString() ) ); storeMutableStringsSelfDelimUTF8( array, offset, length, fbos ); fbos.close(); } /** Stores an array of mutable strings writing to a file in self-delimiting UTF-8 format. * @param array an array of mutable strings. * @param filename a filename. */ public static void storeMutableStringsSelfDelimUTF8( final MutableString[] array, final CharSequence filename ) throws IOException { storeMutableStringsSelfDelimUTF8( array, 0, array.length, filename ); } /** Loads mutable strings from an output stream in self-delimiting UTF-8 format and stores then in an array fragment. * @param is an input stream. * @param array an array of mutable strings. * @param offset the first element of the array to be written. * @param length the number of strings to be loaded. */ public static void loadMutableStringsSelfDelimUTF8( final InputStream is, final MutableString[] array, final int offset, final int length ) throws IOException { ObjectArrays.ensureOffsetLength( array, offset, length ); for( int i = 0; i < length; i++ ) array[ i + offset ].readSelfDelimUTF8( is ); } /** Loads mutable strings from an output stream in self-delimiting UTF-8 format and stores then in an array. * @param is an input stream. * @param array an array of mutable strings. */ public static void loadMutableStringsSelfDelimUTF8( final InputStream is, final MutableString[] array ) throws IOException { loadMutableStringsSelfDelimUTF8( is, array, 0, array.length ); } /** Loads mutable strings from a file in self-delimiting UTF-8 format and stores then in an array fragment. * @param filename a filename. * @param array an array of mutable strings. * @param offset the first element of the array to be written. * @param length the number of strings to be loaded. */ public static void loadMutableStringsSelfDelimUTF8( final CharSequence filename, final MutableString[] array, final int offset, final int length ) throws IOException { FastBufferedInputStream fbis = new FastBufferedInputStream( new FileInputStream( filename.toString() ) ); loadMutableStringsSelfDelimUTF8( fbis, array, offset, length ); fbis.close(); } /** Loads mutable strings from a file in self-delimiting UTF-8 format and stores then in an array. * @param filename a filename. * @param array an array of mutable strings. */ public static void loadMutableStringsSelfDelimUTF8( final CharSequence filename, final MutableString[] array ) throws IOException { loadMutableStringsSelfDelimUTF8( filename, array, 0, array.length ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -