congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JGitFileSystemProvider.newOutputStream
Code IndexAdd Tabnine to your IDE (free)

How to use
newOutputStream
method
in
org.kie.commons.java.nio.fs.jgit.JGitFileSystemProvider

Best Java code snippets using org.kie.commons.java.nio.fs.jgit.JGitFileSystemProvider.newOutputStream (Showing top 20 results out of 315)

origin: org.kie.commons/kie-nio2-jgit

@Override
public void createDirectory( final Path path,
               final FileAttribute<?>... attrs )
    throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
  checkNotNull( "path", path );
  final JGitPathImpl gPath = toPathImpl( path );
  final Pair<PathType, ObjectId> result = checkPath( gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath() );
  if ( !result.getK1().equals( NOT_FOUND ) ) {
    throw new FileAlreadyExistsException( path.toString() );
  }
  try {
    final OutputStream outputStream = newOutputStream( path.resolve( ".gitignore" ) );
    outputStream.write( "# empty\n".getBytes() );
    outputStream.close();
  } catch ( final Exception e ) {
    throw new IOException( e );
  }
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testIsSameFile() throws IOException {
  final URI newRepo = URI.create( "git://issamefile-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@issamefile-test-repo/path/to/myfile1.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  final Path path2 = PROVIDER.getPath( URI.create( "git://user_branch@issamefile-test-repo/path/to/myfile2.txt" ) );
  final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
  outStream2.write( "my cool content".getBytes() );
  outStream2.close();
  final Path path3 = PROVIDER.getPath( URI.create( "git://user_branch@issamefile-test-repo/path/to/myfile3.txt" ) );
  final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
  outStream3.write( "my cool content".getBytes() );
  outStream3.close();
  assertThat( PROVIDER.isSameFile( path, path2 ) ).isTrue();
  assertThat( PROVIDER.isSameFile( path, path3 ) ).isTrue();
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testMoveFiles() throws IOException {
  final URI newRepo = URI.create( "git://moveasset-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@moveasset-test-repo/myfile1.txt" ) );
  {
    final OutputStream outStream = PROVIDER.newOutputStream( path );
    outStream.write( "my cool content".getBytes() );
    outStream.close();
  }
  final Path path2 = PROVIDER.getPath( URI.create( "git://user_branch@moveasset-test-repo/other/path/myfile2.txt" ) );
  {
    final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
    outStream2.write( "my cool content".getBytes() );
    outStream2.close();
  }
  final Path path3 = PROVIDER.getPath( URI.create( "git://user_branch@moveasset-test-repo/myfile3.txt" ) );
  {
    final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
    outStream3.write( "my cool content".getBytes() );
    outStream3.close();
  }
  final Path target = PROVIDER.getPath( URI.create( "git://user_branch@moveasset-test-repo/myfile1.txt" ) );
  try {
    PROVIDER.move( path, target );
  } catch ( final Exception e ) {
    fail( "should move file", e );
  }
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testCopyFiles() throws IOException {
  final URI newRepo = URI.create( "git://copyasset-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@copyasset-test-repo/myfile1.txt" ) );
  {
    final OutputStream outStream = PROVIDER.newOutputStream( path );
    outStream.write( "my cool content".getBytes() );
    outStream.close();
  }
  final Path path2 = PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/other/path/myfile2.txt" ) );
  {
    final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
    outStream2.write( "my cool content".getBytes() );
    outStream2.close();
  }
  final Path path3 = PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/myfile3.txt" ) );
  {
    final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
    outStream3.write( "my cool content".getBytes() );
    outStream3.close();
  }
  final Path target = PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/myfile1.txt" ) );
  PROVIDER.copy( path, target );
  final DirectoryStream<Path> stream = PROVIDER.newDirectoryStream( PROVIDER.getPath( URI.create( "git://user_branch@copyasset-test-repo/" ) ), null );
  for ( Path path1 : stream ) {
    System.out.println("content: " + path1.toUri());
  }
  assertThat( stream ).isNotNull().hasSize( 3 );
}
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testCheckAccess() throws Exception {
  final URI newRepo = URI.create( "git://checkaccess-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@checkaccess-test-repo/path/to/myfile1.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  PROVIDER.checkAccess( path );
  final Path path_to_dir = PROVIDER.getPath( URI.create( "git://master@checkaccess-test-repo/path/to" ) );
  PROVIDER.checkAccess( path_to_dir );
  final Path path_not_exists = PROVIDER.getPath( URI.create( "git://master@checkaccess-test-repo/path/to/some.txt" ) );
  try {
    PROVIDER.checkAccess( path_not_exists );
    failBecauseExceptionWasNotThrown( NoSuchFileException.class );
  } catch ( NoSuchFileException e ) {
  }
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testGetFileStore() throws Exception {
  final URI newRepo = URI.create( "git://filestore-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@filestore-test-repo/path/to/myfile1.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  final FileStore fileStore = PROVIDER.getFileStore( path );
  assertThat( fileStore ).isNotNull();
  assertThat( fileStore.getAttribute( "readOnly" ) ).isEqualTo( Boolean.FALSE );
}
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
final OutputStream outStream4 = PROVIDER.newOutputStream( path4 );
outStream4.write( "my cool content".getBytes() );
outStream4.close();
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testDeleteBranchIfExists() throws IOException {
  final URI newRepo = URI.create( "git://deletebranchifexists1-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://user_branch@deletebranchifexists1-test-repo/path/to/myfile.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  assertThat( outStream ).isNotNull();
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  PROVIDER.newInputStream( path ).close();
  assertThat( PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://user_branch@deletebranchifexists1-test-repo" ) ) ) ).isTrue();
  assertThat( PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://not_user_branch@deletebranchifexists1-test-repo" ) ) ) ).isFalse();
  assertThat( PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://user_branch@deletebranchifexists1-test-repo" ) ) ) ).isFalse();
}
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outRootStream = PROVIDER.newOutputStream( _root );
outRootStream.write( "my cool content".getBytes() );
outRootStream.close();
final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testDeleteBranch() throws IOException {
  final URI newRepo = URI.create( "git://delete-branch-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://user_branch@delete-branch-test-repo/path/to/myfile.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  assertThat( outStream ).isNotNull();
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  PROVIDER.newInputStream( path ).close();
  PROVIDER.delete( PROVIDER.getPath( URI.create( "git://user_branch@delete-branch-test-repo" ) ) );
  try {
    PROVIDER.delete( PROVIDER.getPath( URI.create( "git://user_branch@delete-branch-test-repo" ) ) );
    failBecauseExceptionWasNotThrown( NoSuchFileException.class );
  } catch ( NoSuchFileException ex ) {
  }
  try {
    PROVIDER.delete( PROVIDER.getPath( URI.create( "git://some_user_branch@delete-branch-test-repo" ) ) );
    failBecauseExceptionWasNotThrown( NoSuchFileException.class );
  } catch ( NoSuchFileException ex ) {
  }
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testDeleteIfExists() throws IOException {
  final URI newRepo = URI.create( "git://deleteifexists1-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://user_branch@deleteifexists1-test-repo/path/to/myfile.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  assertThat( outStream ).isNotNull();
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  PROVIDER.newInputStream( path ).close();
  assertThat( PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://user_branch@deleteifexists1-test-repo/non_existent_path" ) ) ) ).isFalse();
  try {
    PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://user_branch@deleteifexists1-test-repo/path/to/" ) ) );
    failBecauseExceptionWasNotThrown( DirectoryNotEmptyException.class );
  } catch ( DirectoryNotEmptyException ex ) {
  }
  assertThat( PROVIDER.deleteIfExists( path ) ).isTrue();
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testIsHidden() throws IOException {
  final URI newRepo = URI.create( "git://ishidden-test-repo" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/path/to/.myfile.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path );
  assertThat( outStream ).isNotNull();
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  final Path path2 = PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/path/to/myfile.txt" ) );
  final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
  assertThat( outStream2 ).isNotNull();
  outStream2.write( "my cool content".getBytes() );
  outStream2.close();
  assertThat( PROVIDER.isHidden( PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/path/to/.myfile.txt" ) ) ) ).isTrue();
  assertThat( PROVIDER.isHidden( PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/path/to/myfile.txt" ) ) ) ).isFalse();
  assertThat( PROVIDER.isHidden( PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/path/to/non_existent/.myfile.txt" ) ) ) ).isTrue();
  assertThat( PROVIDER.isHidden( PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/path/to/non_existent/myfile.txt" ) ) ) ).isFalse();
  assertThat( PROVIDER.isHidden( PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/" ) ) ) ).isFalse();
  assertThat( PROVIDER.isHidden( PROVIDER.getPath( URI.create( "git://user_branch@ishidden-test-repo/some" ) ) ) ).isFalse();
}
origin: org.kie.commons/kie-nio2-jgit

@Test
public void testNewOutputStreamWithJGitOp() throws Exception {
  final File parentFolder = createTempDirectory();
  final File gitFolder = new File( parentFolder, "mytest.git" );
  final Git origin = JGitUtil.newRepository( gitFolder, true );
  commit( origin, "master", "user", "user@example.com", "commit message", null, null, false, new HashMap<String, File>() {{
    put( "myfile.txt", tempFile( "temp\n.origin\n.content" ) );
  }} );
  commit( origin, "user_branch", "user", "user@example.com", "commit message", null, null, false, new HashMap<String, File>() {{
    put( "path/to/some/file/myfile.txt", tempFile( "some\n.content\nhere" ) );
  }} );
  final URI newRepo = URI.create( "git://outstreamwithop-test-repo" );
  final Map<String, Object> env = new HashMap<String, Object>() {{
    put( JGitFileSystemProvider.GIT_DEFAULT_REMOTE_NAME, origin.getRepository().getDirectory().toString() );
  }};
  final FileSystem fs = PROVIDER.newFileSystem( newRepo, env );
  assertThat( fs ).isNotNull();
  final SimpleDateFormat formatter = new SimpleDateFormat( "dd/MM/yyyy" );
  final CommentedOption op = new CommentedOption( "User Tester", "user.tester@example.com", "omg, is it the end?", formatter.parse( "31/12/2012" ) );
  final Path path = PROVIDER.getPath( URI.create( "git://user_branch@outstreamwithop-test-repo/some/path/myfile.txt" ) );
  final OutputStream outStream = PROVIDER.newOutputStream( path, op );
  assertThat( outStream ).isNotNull();
  outStream.write( "my cool content".getBytes() );
  outStream.close();
  final InputStream inStream = PROVIDER.newInputStream( path );
  final String content = new Scanner( inStream ).useDelimiter( "\\A" ).next();
  inStream.close();
  assertThat( content ).isNotNull().isEqualTo( "my cool content" );
}
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
assertThat( outStream ).isNotNull();
outStream.write( "my cool content".getBytes() );
  PROVIDER.newOutputStream( PROVIDER.getPath( URI.create( "git://user_branch@outstream-test-repo/some/path/" ) ) );
  failBecauseExceptionWasNotThrown( org.kie.commons.java.nio.IOException.class );
} catch ( Exception e ) {
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
assertThat( outStream ).isNotNull();
outStream.write( "my cool content".getBytes() );
origin: org.kie.commons/kie-nio2-jgit

final OutputStream outStream = PROVIDER.newOutputStream( path );
outStream.write( "my cool content".getBytes() );
outStream.close();
final OutputStream outStream2 = PROVIDER.newOutputStream( path2 );
outStream2.write( "my cool content".getBytes() );
outStream2.close();
final OutputStream outStream3 = PROVIDER.newOutputStream( path3 );
outStream3.write( "my cool content".getBytes() );
outStream3.close();
org.kie.commons.java.nio.fs.jgitJGitFileSystemProvidernewOutputStream

Popular methods of JGitFileSystemProvider

  • copy
  • createDirectory
  • delete
  • deleteIfExists
  • exists
  • getFileAttributeView
  • getPath
  • getScheme
  • newDirectoryStream
  • newInputStream
  • readAttributes
  • <init>
  • readAttributes,
  • <init>,
  • amend,
  • buildAndStartDaemon,
  • buildCredential,
  • checkAccess,
  • checkAmend,
  • checkURI,
  • composePath

Popular in Java

  • Updating database using SQL prepared statement
  • putExtra (Intent)
  • getApplicationContext (Context)
  • startActivity (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now