/** * Write lines of text to a file. Characters are encoded into bytes using * the {@link StandardCharsets#UTF_8 UTF-8} {@link Charset charset}. * <p> * This method works as if invoking it were equivalent to evaluating the * expression: * <pre>{@code * Files.write(path, lines, StandardCharsets.UTF_8, options); * }</pre> * * @param path the path to the file * @param lines an object to iterate over the char sequences * @param options options specifying how the file is opened * @return the path * @throws UnsupportedOperationException if an unsupported option is specified * @throws SecurityException In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkWrite(String) checkWrite} * method is invoked to check write access to the file. * @since 1.8 */ public static Path write( Path path, Iterable<? extends CharSequence> lines, OpenOption... options ) { return write( path, lines, StandardCharsets.UTF_8, options ); }
public Path fileTB() { Path ret = absTB(); if( !Files.exists( ret ) ) { Filess.write( ret, CONTENT ); } return ret; }
public Path fileTA() { Path ret = absTA(); if( !Files.exists( ret ) ) { Filess.write( ret, CONTENT ); } return ret; }
protected Path orig() { Path ret = dirTA().resolve( "orig" ); if( !Files.exists( ret ) ) { Filess.write( ret, CONTENT ); } return ret; }
public Path fileTAC() { Path ret = dirTA().resolve( nameC() ); if( !Files.exists( ret ) ) { Filess.write( ret, CONTENT ); } return ret; }
public static Path createFile( Path root, byte[] content, String one, String... names ) { Path ret = root.resolve( one ); for( String name : names ) { ret = ret.resolve( name ); } Filess.createDirectories( childGetParent( ret)); Filess.write( ret, content ); return ret; }
public Path fileTAB() { Path ret = dirTA().resolve( nameB() ); if( !Files.exists( ret ) ) { Filess.write( ret, CONTENT ); } return ret; }
public Path fileTAD() { Path ret = dirTA().resolve( nameD() ); if( !Files.exists( ret ) ) { Filess.write( ret, CONTENT ); } return ret; }
protected Path targetFile() { Path target = absT().resolve( "targetSpace" ).resolve( "target" ); if( Files.exists( target ) ) { return target; } Filess.createDirectories( childGetParent( target ) ); Filess.write( target, CONTENT ); return target; }
@Test @Category( Writable.class ) public void testWriteSmallChunks() { Path target = absTA(); Filess.write( target, Arrays.copyOfRange( CONTENT, 0, 3 ) ); Filess.write( target, Arrays.copyOfRange( CONTENT, 3, CONTENT.length ), APPEND ); assertThat( Filess.readAllBytes( target ) ).isEqualTo( CONTENT ); }
protected Path otherProviderFileA() { Path ret = otherProviderAbsA(); if( !Files.exists( ret ) ) { Filess.createDirectories( childGetParent( ret ) ); Filess.write( ret, CONTENT ); } return ret; }
protected Path otherProviderTargetDir() { Path target = otherProviderAbsA().resolve( "target" ); if( !Files.exists( target ) ) { Filess.createDirectories( target ); Filess.write( otherProviderTargetDirKid(), CONTENT ); // one kid } return target; }
protected Path otherProviderTargetFile() { Path target = otherProviderAbsA().resolve( nameB() ); if( !Files.exists( target ) ) { Filess.createDirectories( childGetParent( target ) ); Filess.write( target, CONTENT ); } return target; }
protected Path srcFile() { if( Files.exists( src() ) ) { return src(); } Filess.write( src(), CONTENT ); return src(); }
private Path targetDir() { Path target = childGetParent( targetDirKid() ); if( !Files.exists( target ) ) { Filess.createDirectories( target ); Filess.write( targetDirKid(), CONTENT ); // one kid } return target; }