當前位置: 首頁>>代碼示例>>Java>>正文


Java IO類代碼示例

本文整理匯總了Java中io.advantageous.boon.core.IO的典型用法代碼示例。如果您正苦於以下問題:Java IO類的具體用法?Java IO怎麽用?Java IO使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IO類屬於io.advantageous.boon.core包,在下文中一共展示了IO類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: NumberValue

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public NumberValue( boolean chop, TypeType type, int startIndex, int endIndex, char[] buffer ) {
    this.type = type;


    try {
        if ( chop ) {

            this.buffer = Arrays.copyOfRange ( buffer, startIndex, endIndex );
            this.startIndex = 0;
            this.endIndex = this.buffer.length;
            chopped = true;
        } else {
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            this.buffer = buffer;
        }
    } catch ( Exception ex ) {
        IO.puts("exception", ex, "start", startIndex, "end", endIndex);
        Exceptions.handle(ex);

    }
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:23,代碼來源:NumberValue.java

示例2: getWebPageContents

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public String getWebPageContents() {

        if (webPageContents == null || webPageContents.isEmpty()) {

            final String htmlPageLocationInitial = getHtmlPageLocation();
            final String pageLocation;
            pageLocation = htmlPageLocationInitial.startsWith("/") ?
                    htmlPageLocationInitial.substring(1, htmlPageLocationInitial.length()) :
                    htmlPageLocationInitial;

            webPageContents = IO.read(
                    Thread.currentThread()
                            .getContextClassLoader()
                            .getResourceAsStream(pageLocation)
            );
        }
        return webPageContents;
    }
 
開發者ID:advantageous,項目名稱:qbit,代碼行數:19,代碼來源:AdminBuilder.java

示例3: readBody

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public static String readBody(final HttpServletRequest request) {
    try {
        final ServletInputStream inputStream = request.getInputStream();
        final String read = IO.read(inputStream, StandardCharsets.UTF_8);
        inputStream.close();
        return read;
    } catch (final IOException e) {
        throw new IllegalStateException(e);
    }
}
 
開發者ID:advantageous,項目名稱:qbit-extensions,代碼行數:11,代碼來源:QBitServletUtil.java

示例4: parse

import io.advantageous.boon.core.IO; //導入依賴的package包/類
@Override
public final <T> T parse( Class<T> type, Reader reader ) {

    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    charBuf = IO.read( reader, charBuf, bufSize, copyBuf );
    return parse( type, charBuf.readForRecycle() );

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:12,代碼來源:JsonMappingParser.java

示例5: parseAsStream

import io.advantageous.boon.core.IO; //導入依賴的package包/類
@Override
public final <T> T parseAsStream( Class<T> type, byte[] value ) {
    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    charBuf = IO.read( new InputStreamReader ( new InMemoryInputStream(value), charset ), charBuf, value.length, copyBuf );
    return this.basicParser.parse ( type, charBuf.readForRecycle () );
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:10,代碼來源:JsonMappingParser.java

示例6: parse

import io.advantageous.boon.core.IO; //導入依賴的package包/類
@Override
public  Object parse(  Reader reader ) {

    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    fileInputBuf = IO.read ( reader, fileInputBuf, bufSize, copyBuf );
    return parse( fileInputBuf.readForRecycle() );

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:12,代碼來源:BaseJsonParser.java

示例7: parse

import io.advantageous.boon.core.IO; //導入依賴的package包/類
@Override
public  <T> T parse( Class<T> type, Reader reader ) {

    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    fileInputBuf = IO.read( reader, fileInputBuf, bufSize, copyBuf );
    return parse( type, fileInputBuf.readForRecycle() );

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:12,代碼來源:BaseJsonParserAndMapper.java

示例8: initializePath

import io.advantageous.boon.core.IO; //導入依賴的package包/類
private void initializePath() {
    String cmd = commandLine.get( 0 );
    Path pathCommand = IO.path(cmd);
    if ( !Files.exists( pathCommand ) ) {
        for ( Path dir : path ) {
            pathCommand = IO.path( dir, cmd );
            if ( Files.exists( pathCommand ) ) {
                cmd = pathCommand.toAbsolutePath().toString();
                break;
            }
        }
    }
    commandLine.set( 0, cmd );

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:16,代碼來源:Runner.java

示例9: puts

import io.advantageous.boon.core.IO; //導入依賴的package包/類
/**
 * Like print, but prints out a whole slew of objects on the same line.
 *
 * @param messages objects you want to print on the same line.
 */
public static void puts(Object... messages) {

    for (Object message : messages) {
        IO.print(message);
        if (!(message instanceof Terminal.Escape)) IO.print(' ');
    }
    IO.println();

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:15,代碼來源:Terminal.java

示例10: handle

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public void handle( HttpExchange t ) throws IOException {

            InputStream requestBody = t.getRequestBody();
            String body = IO.read( requestBody );
            Headers requestHeaders = t.getRequestHeaders();
            body = body + "\n" + copy( requestHeaders ).toString();
            t.sendResponseHeaders( 200, body.length() );
            OutputStream os = t.getResponseBody();
            os.write( body.getBytes() );
            os.close();
        }
 
開發者ID:advantageous,項目名稱:boon,代碼行數:12,代碼來源:HTTPTest.java

示例11: writeValue

import io.advantageous.boon.core.IO; //導入依賴的package包/類
@Override
public void writeValue( File dest, Object value ) {
    IO.write( Paths.get(dest.toString()), serializerFactory.create().serialize(value).toString());
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:5,代碼來源:ObjectMapperImpl.java

示例12: parse

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public <T> T parse( Class<T> type, InputStream input ) {
    return parse( type, IO.input(input) );
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:4,代碼來源:JsonBaseByteArrayParser.java

示例13: parseFile

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public <T> T parseFile( Class<T> type, String fileName ) {
    return parse(type, IO.input ( fileName ));
}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:4,代碼來源:JsonBaseByteArrayParser.java

示例14: part9Options

import io.advantageous.boon.core.IO; //導入依賴的package包/類
public static void part9Options() throws Exception {

        puts ("\n\n\n", "\npart9Options");


        JsonParserFactory jsonParserFactory = new JsonParserFactory()
                .useFieldsFirst().useFieldsOnly().usePropertiesFirst().usePropertyOnly() //one of these
                .lax() //allow loose parsing of JSON like JSON Smart
                .strict() //opposite of lax
                .setCharset( StandardCharsets.UTF_8 ) //Set the standard charset, defaults to UTF_8
                .setChop( true ) //chops up buffer overlay buffer (more discussion of this later)
                .setLazyChop( true ) //similar to chop but only does it after map.get
                ;

        JsonSerializerFactory jsonSerializerFactory = new JsonSerializerFactory()
                .useFieldsFirst().useFieldsOnly().usePropertiesFirst().usePropertyOnly() //one of these
                //.addPropertySerializer(  )  customize property output
                //.addTypeSerializer(  )      customize type output
                .useJsonFormatForDates() //use json dates
                //.addFilter(  )   add a property filter to exclude properties
                .includeEmpty().includeNulls().includeDefaultValues() //override defaults
                .handleComplexBackReference() //uses identity map to track complex back reference and avoid them
                .setHandleSimpleBackReference( true ) //looks for simple back reference for parent
                .setCacheInstances( true ) //turns on caching for immutable objects
                ;



        final User diana = BeanUtils.copy( user );
        final User rick = BeanUtils.copy( user );
        diana.getName().setFirst( "Diana" );
        diana.setGender( User.Gender.FEMALE );
        rick.getName().setFirst( "Rick" );
        diana.setBirthDate( Dates.getUSDate( 8, 21, 1984 ) );
        List<User> users = Lists.list(  rick, diana );

        //You can use parser and serializer directly.
        final JsonParserAndMapper jsonParserAndMapper = jsonParserFactory.create();
        final JsonSerializer jsonSerializer = jsonSerializerFactory.create();

        File file = File.createTempFile( "userList", ".json" );
        String jsonString = jsonSerializer.serialize( users ).toString();

        puts( "JSON STRING", jsonString );

        IO.write( file.toString(), jsonString);
        List<User> users2 = jsonParserAndMapper.parseListFromFile( User.class, file.toString() );

        //Or you can pass them to the ObjectMapper interface you know and love, just pass the factories to it.
        ObjectMapper mapper = JsonFactory.create( jsonParserFactory, jsonSerializerFactory );


        mapper.writeValue( file, users  );
        List<User> userList = mapper.readValue( file, List.class, User.class  );
        puts (userList);
        puts ( mapper.writeValueAsString( userList ) );

        puts (userList);
        puts (users);
        boolean ok = userList.toString().equals ( users.toString() ) || die ( userList.toString() );



    }
 
開發者ID:advantageous,項目名稱:boon,代碼行數:65,代碼來源:JsonTutorial.java

示例15: test

import io.advantageous.boon.core.IO; //導入依賴的package包/類
@Test
public void test() {

    List<String> files  = IO.listByFileExtension ( "./files/", "json" );

    for ( String file : files) {
        //outputs ( file );

        Object object  =  new JsonParserFactory().createFastParser().parseFile ( Map.class, file.toString () );


        walkObject( object, null, null );

    }

    //outputs ( "leaf", leafCount, "map", mapCount, "collection", collectionCount );
    //outputs ( "integer", integerCount, "long", longCount, "double", doubleCount, "boolean", booleanCount );
    //outputs ( "string", stringCount, "date", dateCount, "null", nullCount );

}
 
開發者ID:advantageous,項目名稱:boon,代碼行數:21,代碼來源:LazyValueMapTest.java


注:本文中的io.advantageous.boon.core.IO類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。